add limit to the number of peers to connect to from px

This commit is contained in:
vyzo 2019-12-05 18:53:41 +02:00
parent f20f93004b
commit 17fd85f02c
1 changed files with 5 additions and 0 deletions

View File

@ -383,7 +383,12 @@ func (gs *GossipSubRouter) addBackoff(p peer.ID, topic string) {
}
func (gs *GossipSubRouter) pxConnect(peers []*pb.PeerInfo) {
if len(peers) > GossipSubPrunePeers {
peers = peers[:GossipSubPrunePeers]
}
toconnect := make([]connectInfo, 0, len(peers))
for _, pi := range peers {
p := peer.ID(pi.PeerID)