Skip to content

Commit 86e7790

Browse files
authored
Merge pull request #19351 from karalabe/txpool-precache-signatures
core: cache tx signature before obtaining lock
2 parents 5b0d3fa + fbe7caf commit 86e7790

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎core/tx_pool.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,9 @@ func (pool *TxPool) AddRemotes(txs []*types.Transaction) []error {
833833

834834
// addTx enqueues a single transaction into the pool if it is valid.
835835
func (pool *TxPool) addTx(tx *types.Transaction, local bool) error {
836+
// Cache sender in transaction before obtaining lock (pool.signer is immutable)
837+
types.Sender(pool.signer, tx)
838+
836839
pool.mu.Lock()
837840
defer pool.mu.Unlock()
838841

@@ -851,6 +854,10 @@ func (pool *TxPool) addTx(tx *types.Transaction, local bool) error {
851854

852855
// addTxs attempts to queue a batch of transactions if they are valid.
853856
func (pool *TxPool) addTxs(txs []*types.Transaction, local bool) []error {
857+
// Cache senders in transactions before obtaining lock (pool.signer is immutable)
858+
for _, tx := range txs {
859+
types.Sender(pool.signer, tx)
860+
}
854861
pool.mu.Lock()
855862
defer pool.mu.Unlock()
856863

0 commit comments

Comments
 (0)