1
0
Fork 0
forked from forks/go-ethereum

core/txpool/legacypool: fix data race of txlookup access (#31641)

This commit is contained in:
Miro 2025-04-16 22:36:53 -04:00 committed by GitHub
parent 846d578cc3
commit 87974974a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)