mirror of
https://github.com/tendermint/tendermint.git
synced 2026-03-27 12:05:02 +00:00
actually shuffle peers more
This commit is contained in:
@@ -876,6 +876,7 @@ func (m *PeerManager) Advertise(peerID types.NodeID, limit uint16) []NodeAddress
|
||||
addresses = append(addresses, m.options.SelfAddress)
|
||||
}
|
||||
|
||||
OUTER:
|
||||
for _, peer := range m.store.Ranked() {
|
||||
if peer.ID == peerID {
|
||||
continue
|
||||
@@ -885,8 +886,8 @@ func (m *PeerManager) Advertise(peerID types.NodeID, limit uint16) []NodeAddress
|
||||
}
|
||||
|
||||
for nodeAddr, addressInfo := range peer.AddressInfo {
|
||||
if len(addresses) >= int(limit) {
|
||||
return addresses
|
||||
if len(addresses) >= int(limit)*2 {
|
||||
break OUTER
|
||||
}
|
||||
|
||||
// only add non-private NodeIDs
|
||||
@@ -895,6 +896,7 @@ func (m *PeerManager) Advertise(peerID types.NodeID, limit uint16) []NodeAddress
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rand.Shuffle(len(addresses), func(i, j int) {
|
||||
addresses[i], addresses[j] = addresses[j], addresses[i]
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user