mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-15 17:30:44 +00:00
parent
c922f26d0c
commit
0ad629d484
1 changed files with 6 additions and 7 deletions
|
|
@ -18,9 +18,11 @@
|
||||||
package p2p
|
package p2p
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"errors"
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
|
"slices"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -1046,12 +1048,9 @@ func (srv *Server) PeersInfo() []*PeerInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sort the result array alphabetically by node identifier
|
// Sort the result array alphabetically by node identifier
|
||||||
for i := 0; i < len(infos); i++ {
|
slices.SortFunc(infos, func(a, b *PeerInfo) int {
|
||||||
for j := i + 1; j < len(infos); j++ {
|
return cmp.Compare(a.ID, b.ID)
|
||||||
if infos[i].ID > infos[j].ID {
|
})
|
||||||
infos[i], infos[j] = infos[j], infos[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return infos
|
return infos
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue