mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-15 04:26:37 +00:00
core/txpool: use cmp.Compare instead of subtraction (#34918)
This fixes a theoretical overflow condition if an account has an impossibly high nonce.
This commit is contained in:
parent
bcb68d23b3
commit
7facf9c129
1 changed files with 2 additions and 1 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
package locals
|
package locals
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"slices"
|
"slices"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -151,7 +152,7 @@ func (tracker *TxTracker) recheck(journalCheck bool) []*types.Transaction {
|
||||||
for _, list := range rejournal {
|
for _, list := range rejournal {
|
||||||
// cmp(a, b) should return a negative number when a < b,
|
// cmp(a, b) should return a negative number when a < b,
|
||||||
slices.SortFunc(list, func(a, b *types.Transaction) int {
|
slices.SortFunc(list, func(a, b *types.Transaction) int {
|
||||||
return int(a.Nonce() - b.Nonce())
|
return cmp.Compare(a.Nonce(), b.Nonce())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// Rejournal the tracker while holding the lock. No new transactions will
|
// Rejournal the tracker while holding the lock. No new transactions will
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue