Skip to content

Commit fbae079

Browse files
authored
core/txpool/locals: fix unsafe nonce comparator in TxTracker.recheck journal sort
1 parent 960c87a commit fbae079

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core/txpool/locals/tx_tracker.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,13 @@ func (tracker *TxTracker) recheck(journalCheck bool) []*types.Transaction {
151151
for _, list := range rejournal {
152152
// cmp(a, b) should return a negative number when a < b,
153153
slices.SortFunc(list, func(a, b *types.Transaction) int {
154-
return int(a.Nonce() - b.Nonce())
154+
if a.Nonce() < b.Nonce() {
155+
return -1
156+
}
157+
if a.Nonce() > b.Nonce() {
158+
return 1
159+
}
160+
return 0
155161
})
156162
}
157163
// Rejournal the tracker while holding the lock. No new transactions will

0 commit comments

Comments
 (0)