From 17fd85f02c85e1c7f17f92f549677d0273371399 Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 5 Dec 2019 18:53:41 +0200 Subject: [PATCH] add limit to the number of peers to connect to from px --- gossipsub.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gossipsub.go b/gossipsub.go index 7bb2330..43a82ca 100644 --- a/gossipsub.go +++ b/gossipsub.go @@ -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)