forked from forks/go-ethereum
core/txpool/legacypool: fix data race of txlookup access (#31641)
This commit is contained in:
parent
846d578cc3
commit
87974974a7
1 changed files with 11 additions and 1 deletions
|
|
@ -1827,6 +1827,16 @@ func (t *lookup) Remove(hash common.Hash) {
|
|||
delete(t.txs, hash)
|
||||
}
|
||||
|
||||
// Clear resets the lookup structure, removing all stored entries.
|
||||
func (t *lookup) Clear() {
|
||||
t.lock.Lock()
|
||||
defer t.lock.Unlock()
|
||||
|
||||
t.slots = 0
|
||||
t.txs = make(map[common.Hash]*types.Transaction)
|
||||
t.auths = make(map[common.Address][]common.Hash)
|
||||
}
|
||||
|
||||
// TxsBelowTip finds all remote transactions below the given tip threshold.
|
||||
func (t *lookup) TxsBelowTip(threshold *big.Int) types.Transactions {
|
||||
found := make(types.Transactions, 0, 128)
|
||||
|
|
@ -1923,7 +1933,7 @@ func (pool *LegacyPool) Clear() {
|
|||
for addr := range pool.queue {
|
||||
pool.reserver.Release(addr)
|
||||
}
|
||||
pool.all = newLookup()
|
||||
pool.all.Clear()
|
||||
pool.priced = newPricedList(pool.all)
|
||||
pool.pending = make(map[common.Address]*list)
|
||||
pool.queue = make(map[common.Address]*list)
|
||||
|
|
|
|||
Loading…
Reference in a new issue