From 84f76ca8c5b3d469f34475b65ad6a5ae280ffc70 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Mon, 26 Sep 2022 11:34:15 +0200 Subject: [PATCH] core: fix datarace in txpool, fixes #25870 and #25869 (#25872) core: fix datarace in txpool pendingnoce, fixes #25870 --- core/tx_pool.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/tx_pool.go b/core/tx_pool.go index 22328963dfb1..ee8b9f7a43f0 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -463,6 +463,9 @@ func (pool *TxPool) SetGasPrice(price *big.Int) { // Nonce returns the next nonce of an account, with all transactions executable // by the pool already applied on top. func (pool *TxPool) Nonce(addr common.Address) uint64 { + pool.mu.RLock() + defer pool.mu.RUnlock() + return pool.pendingNonces.get(addr) }