mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
core/txpool/legacypool: fix data race in Add
This commit is contained in:
parent
476f117211
commit
5d113eea32
1 changed files with 4 additions and 1 deletions
|
|
@ -943,8 +943,11 @@ func (pool *LegacyPool) Add(txs []*types.Transaction, sync bool) []error {
|
|||
news = make([]*types.Transaction, 0, len(txs))
|
||||
)
|
||||
for i, tx := range txs {
|
||||
pool.mu.Lock()
|
||||
hash := pool.all.Get(tx.Hash())
|
||||
pool.mu.Unlock()
|
||||
// If the transaction is known, pre-set the error slot
|
||||
if pool.all.Get(tx.Hash()) != nil {
|
||||
if hash != nil {
|
||||
errs[i] = txpool.ErrAlreadyKnown
|
||||
knownTxMeter.Mark(1)
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in a new issue