mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +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))
|
news = make([]*types.Transaction, 0, len(txs))
|
||||||
)
|
)
|
||||||
for i, tx := range 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 the transaction is known, pre-set the error slot
|
||||||
if pool.all.Get(tx.Hash()) != nil {
|
if hash != nil {
|
||||||
errs[i] = txpool.ErrAlreadyKnown
|
errs[i] = txpool.ErrAlreadyKnown
|
||||||
knownTxMeter.Mark(1)
|
knownTxMeter.Mark(1)
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue