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