From 2fd4f2c7b785e40c024afb31f4b8f1b50404a3e9 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 15 Feb 2024 11:46:36 +0100 Subject: [PATCH] Update list.go --- core/txpool/legacypool/list.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/txpool/legacypool/list.go b/core/txpool/legacypool/list.go index 2be1c0fa9d..ba2c829c40 100644 --- a/core/txpool/legacypool/list.go +++ b/core/txpool/legacypool/list.go @@ -160,13 +160,14 @@ func (m *sortedMap) Cap(threshold int) types.Transactions { } // Otherwise gather and drop the highest nonce'd transactions var drops types.Transactions - - slices.Sort(*m.index) // the sorted array is a heap, so no need to reheap after deleting tail items + slices.Sort(*m.index) for size := len(m.items); size > threshold; size-- { drops = append(drops, m.items[(*m.index)[size-1]]) delete(m.items, (*m.index)[size-1]) } *m.index = (*m.index)[:threshold] + // The sorted m.index slice is still a valid heap, so there is no need to + // reheap after deleting tail items. // If we had a cache, shift the back m.cacheMu.Lock()