all: update golang/x/ext and fix slice sorting fallout (#27909)
The Go authors updated golang/x/ext to change the function signature of the slices sort method. It's an entire shitshow now because x/ext is not tagged, so everyone's codebase just picked a new version that some other dep depends on, causing our code to fail building. This PR updates the dep on our code too and does all the refactorings to follow upstream...
This commit is contained in:
@@ -902,9 +902,9 @@ func WriteBadBlock(db ethdb.KeyValueStore, block *types.Block) {
|
||||
Header: block.Header(),
|
||||
Body: block.Body(),
|
||||
})
|
||||
slices.SortFunc(badBlocks, func(a, b *badBlock) bool {
|
||||
slices.SortFunc(badBlocks, func(a, b *badBlock) int {
|
||||
// Note: sorting in descending number order.
|
||||
return a.Header.Number.Uint64() >= b.Header.Number.Uint64()
|
||||
return -a.Header.Number.Cmp(b.Header.Number)
|
||||
})
|
||||
if len(badBlocks) > badBlockToKeep {
|
||||
badBlocks = badBlocks[:badBlockToKeep]
|
||||
|
||||
@@ -19,12 +19,12 @@ package rawdb
|
||||
import (
|
||||
"math/big"
|
||||
"reflect"
|
||||
"sort"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
func TestChainIterator(t *testing.T) {
|
||||
@@ -92,11 +92,9 @@ func TestChainIterator(t *testing.T) {
|
||||
}
|
||||
}
|
||||
if !c.reverse {
|
||||
slices.Sort(numbers)
|
||||
sort.Ints(numbers)
|
||||
} else {
|
||||
slices.SortFunc(numbers, func(a, b int) bool {
|
||||
return a > b // Sort descending
|
||||
})
|
||||
sort.Sort(sort.Reverse(sort.IntSlice(numbers)))
|
||||
}
|
||||
if !reflect.DeepEqual(numbers, c.expect) {
|
||||
t.Fatalf("Case %d failed, visit element mismatch, want %v, got %v", i, c.expect, numbers)
|
||||
|
||||
Reference in New Issue
Block a user