aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
author贺鹏飞 <hpf@hackerful.cn>2019-03-06 22:31:41 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-03-29 18:01:29 +0800
commitfbe7caf13621e160cf8a1c6443016e4c012a9e53 (patch)
tree9d373c9f8bcea73737219d0ad6c3ea04dd55ca27 /core
parent5b0d3fa39359c027882705c221b6ddb5cd73f3d9 (diff)
downloadgo-tangerine-fbe7caf13621e160cf8a1c6443016e4c012a9e53.tar
go-tangerine-fbe7caf13621e160cf8a1c6443016e4c012a9e53.tar.gz
go-tangerine-fbe7caf13621e160cf8a1c6443016e4c012a9e53.tar.bz2
go-tangerine-fbe7caf13621e160cf8a1c6443016e4c012a9e53.tar.lz
go-tangerine-fbe7caf13621e160cf8a1c6443016e4c012a9e53.tar.xz
go-tangerine-fbe7caf13621e160cf8a1c6443016e4c012a9e53.tar.zst
go-tangerine-fbe7caf13621e160cf8a1c6443016e4c012a9e53.zip
core: cache tx signature before obtaining lock
Diffstat (limited to 'core')
-rw-r--r--core/tx_pool.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/tx_pool.go b/core/tx_pool.go
index 305dfcc22..411143aea 100644
--- a/core/tx_pool.go
+++ b/core/tx_pool.go
@@ -833,6 +833,9 @@ func (pool *TxPool) AddRemotes(txs []*types.Transaction) []error {
// addTx enqueues a single transaction into the pool if it is valid.
func (pool *TxPool) addTx(tx *types.Transaction, local bool) error {
+ // Cache sender in transaction before obtaining lock (pool.signer is immutable)
+ types.Sender(pool.signer, tx)
+
pool.mu.Lock()
defer pool.mu.Unlock()
@@ -851,6 +854,10 @@ func (pool *TxPool) addTx(tx *types.Transaction, local bool) error {
// addTxs attempts to queue a batch of transactions if they are valid.
func (pool *TxPool) addTxs(txs []*types.Transaction, local bool) []error {
+ // Cache senders in transactions before obtaining lock (pool.signer is immutable)
+ for _, tx := range txs {
+ types.Sender(pool.signer, tx)
+ }
pool.mu.Lock()
defer pool.mu.Unlock()