mirror of
https://github.com/yggdrasil-network/yggdrasil-go
synced 2024-11-09 15:10:26 +03:00
Improve getPeers
sorting
This commit is contained in:
parent
1e9a59edf9
commit
768278a8e6
@ -56,10 +56,16 @@ func (a *AdminSocket) getPeersHandler(req *GetPeersRequest, res *GetPeersRespons
|
|||||||
res.Peers = append(res.Peers, peer)
|
res.Peers = append(res.Peers, peer)
|
||||||
}
|
}
|
||||||
sort.Slice(res.Peers, func(i, j int) bool {
|
sort.Slice(res.Peers, func(i, j int) bool {
|
||||||
if res.Peers[i].Port == res.Peers[j].Port {
|
if res.Peers[i].Inbound == res.Peers[j].Inbound {
|
||||||
return res.Peers[i].Priority < res.Peers[j].Priority
|
if res.Peers[i].PublicKey == res.Peers[j].PublicKey {
|
||||||
|
if res.Peers[i].Priority == res.Peers[j].Priority {
|
||||||
|
return res.Peers[i].Uptime > res.Peers[j].Uptime
|
||||||
|
}
|
||||||
|
return res.Peers[i].Priority < res.Peers[j].Priority
|
||||||
|
}
|
||||||
|
return res.Peers[i].PublicKey < res.Peers[j].PublicKey
|
||||||
}
|
}
|
||||||
return res.Peers[i].Port < res.Peers[j].Port
|
return !res.Peers[i].Inbound && res.Peers[j].Inbound
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user