mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
eth/fetcher: using slices.SortFunc
This commit is contained in:
parent
684f0db4a2
commit
726528e83e
1 changed files with 3 additions and 2 deletions
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
mrand "math/rand"
|
mrand "math/rand"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -1014,8 +1015,8 @@ func (f *TxFetcher) forEachAnnounce(announces map[common.Hash]*txMetadataWithSeq
|
||||||
for hash, entry := range announces {
|
for hash, entry := range announces {
|
||||||
list = append(list, announcement{hash: hash, meta: entry.txMetadata, seq: entry.seq})
|
list = append(list, announcement{hash: hash, meta: entry.txMetadata, seq: entry.seq})
|
||||||
}
|
}
|
||||||
sort.Slice(list, func(i, j int) bool {
|
slices.SortFunc(list, func(a, b announcement) int {
|
||||||
return list[i].seq < list[j].seq
|
return int(a.seq) - int(b.seq)
|
||||||
})
|
})
|
||||||
for i := range list {
|
for i := range list {
|
||||||
if !do(list[i].hash, list[i].meta) {
|
if !do(list[i].hash, list[i].meta) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue