core: fix datarace in txpool, fixes #25870 and #25869 (#25872)

core: fix datarace in txpool pendingnoce, fixes #25870
This commit is contained in:
Martin Holst Swende 2022-09-26 11:34:15 +02:00 committed by Daniel Liu
parent 66763aa8ae
commit 05797846fc

View file

@ -499,6 +499,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)
}