We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d34f9af + 6a69b16 commit c227603Copy full SHA for c227603
p2p/server.go
@@ -19,6 +19,7 @@ package p2p
19
20
import (
21
"bytes"
22
+ "cmp"
23
"crypto/ecdsa"
24
"encoding/hex"
25
"errors"
@@ -1140,12 +1141,9 @@ func (srv *Server) PeersInfo() []*PeerInfo {
1140
1141
}
1142
1143
// Sort the result array alphabetically by node identifier
- for i := 0; i < len(infos); i++ {
1144
- for j := i + 1; j < len(infos); j++ {
1145
- if infos[i].ID > infos[j].ID {
1146
- infos[i], infos[j] = infos[j], infos[i]
1147
- }
1148
1149
+ slices.SortFunc(infos, func(a, b *PeerInfo) int {
+ return cmp.Compare(a.ID, b.ID)
+ })
+
1150
return infos
1151
0 commit comments