core/txpool/locals: fix unsafe nonce comparator in TxTracker.recheck journal sort

This commit is contained in:
Snezhkko 2025-11-26 10:20:01 +02:00 committed by GitHub
parent 960c87a944
commit fbae079252
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -151,7 +151,13 @@ func (tracker *TxTracker) recheck(journalCheck bool) []*types.Transaction {
for _, list := range rejournal {
// cmp(a, b) should return a negative number when a < b,
slices.SortFunc(list, func(a, b *types.Transaction) int {
return int(a.Nonce() - b.Nonce())
if a.Nonce() < b.Nonce() {
return -1
}
if a.Nonce() > b.Nonce() {
return 1
}
return 0
})
}
// Rejournal the tracker while holding the lock. No new transactions will