forked from cerc-io/plugeth
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:
@@ -217,14 +217,14 @@ func nodeEqual(n1 *enode.Node, n2 *enode.Node) bool {
|
||||
}
|
||||
|
||||
func sortByID(nodes []*enode.Node) {
|
||||
slices.SortFunc(nodes, func(a, b *enode.Node) bool {
|
||||
return string(a.ID().Bytes()) < string(b.ID().Bytes())
|
||||
slices.SortFunc(nodes, func(a, b *enode.Node) int {
|
||||
return bytes.Compare(a.ID().Bytes(), b.ID().Bytes())
|
||||
})
|
||||
}
|
||||
|
||||
func sortedByDistanceTo(distbase enode.ID, slice []*node) bool {
|
||||
return slices.IsSortedFunc(slice, func(a, b *node) bool {
|
||||
return enode.DistCmp(distbase, a.ID(), b.ID()) < 0
|
||||
return slices.IsSortedFunc(slice, func(a, b *node) int {
|
||||
return enode.DistCmp(distbase, a.ID(), b.ID())
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -302,8 +302,8 @@ func (tn *preminedTestnet) closest(n int) (nodes []*enode.Node) {
|
||||
nodes = append(nodes, tn.node(d, i))
|
||||
}
|
||||
}
|
||||
slices.SortFunc(nodes, func(a, b *enode.Node) bool {
|
||||
return enode.DistCmp(tn.target.id(), a.ID(), b.ID()) < 0
|
||||
slices.SortFunc(nodes, func(a, b *enode.Node) int {
|
||||
return enode.DistCmp(tn.target.id(), a.ID(), b.ID())
|
||||
})
|
||||
return nodes[:n]
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ func TestUDPv5_lookupE2E(t *testing.T) {
|
||||
for i := range nodes {
|
||||
expectedResult[i] = nodes[i].Self()
|
||||
}
|
||||
slices.SortFunc(expectedResult, func(a, b *enode.Node) bool {
|
||||
return enode.DistCmp(target.ID(), a.ID(), b.ID()) < 0
|
||||
slices.SortFunc(expectedResult, func(a, b *enode.Node) int {
|
||||
return enode.DistCmp(target.ID(), a.ID(), b.ID())
|
||||
})
|
||||
|
||||
// Do the lookup.
|
||||
|
||||
Reference in New Issue
Block a user