From 0b92dde99256500332771daac1f555176395e754 Mon Sep 17 00:00:00 2001 From: Bharath Date: Mon, 6 Jan 2025 11:34:53 +0530 Subject: [PATCH] avoid cleaning up duplicate addresses --- core/txpool/legacypool/legacypool.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index 46e594d7d..b1397292a 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -1782,7 +1782,7 @@ func (pool *LegacyPool) truncateQueue() { // it assumes that the pool lock is being held func (pool *LegacyPool) clearPendingAndQueued(newHead *types.Header) { // Iterate over all accounts and demote any non-executable transactions - addrsForWhichTxsRemoved := []common.Address{} + addrsForWhichTxsRemoved := map[common.Address]bool{} for addr, list := range pool.pending { dropped, invalids := list.ClearList() @@ -1800,7 +1800,7 @@ func (pool *LegacyPool) clearPendingAndQueued(newHead *types.Header) { delete(pool.pending, addr) delete(pool.beats, addr) - addrsForWhichTxsRemoved = append(addrsForWhichTxsRemoved, addr) + addrsForWhichTxsRemoved[addr] = true } } @@ -1817,10 +1817,12 @@ func (pool *LegacyPool) clearPendingAndQueued(newHead *types.Header) { if list.Empty() { delete(pool.queue, addr) + + addrsForWhichTxsRemoved[addr] = true } } - for _, addr := range addrsForWhichTxsRemoved { + for addr := range addrsForWhichTxsRemoved { pool.reserve(addr, false) } }