From 2b9e72c7bf56ba98b0876883f2c6a2c90a832e75 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Tue, 13 Feb 2024 21:43:44 +0800 Subject: [PATCH] Revert "refactor Cap to use heap.Pop() instead of sorting the whole heap" This reverts commit e8b23da4cd6c1e4e8fd6fdb239bc486ba2debf5b. --- core/txpool/legacypool/list.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/txpool/legacypool/list.go b/core/txpool/legacypool/list.go index de7db2ac49..2b3bde6384 100644 --- a/core/txpool/legacypool/list.go +++ b/core/txpool/legacypool/list.go @@ -160,11 +160,12 @@ func (m *sortedMap) Cap(threshold int) types.Transactions { // Otherwise gather and drop the highest nonce'd transactions var drops types.Transactions + sort.Sort(*m.index) for size := len(m.items); size > threshold; size-- { - dropIdx := m.index.Pop().(uint64) - drops = append(drops, m.items[dropIdx]) - delete(m.items, dropIdx) + drops = append(drops, m.items[(*m.index)[size-1]]) + delete(m.items, (*m.index)[size-1]) } + *m.index = (*m.index)[:threshold] // If we had a cache, shift the back m.cacheMu.Lock()