Revert "refactor Cap to use heap.Pop() instead of sorting the whole heap"

This reverts commit e8b23da4cd.
This commit is contained in:
colinlyguo 2024-02-13 21:43:44 +08:00
parent e8b23da4cd
commit 2b9e72c7bf
No known key found for this signature in database
GPG key ID: 82E123BE1B68288B

View file

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