From 76d8fd687d10920c111c775b18b021a73bfda2ca Mon Sep 17 00:00:00 2001 From: Prem Chaitanya Prathi Date: Tue, 30 Jul 2024 11:02:59 +0530 Subject: [PATCH] fix: use total peers for pubsubTopic as out peers target (#1170) --- waku/v2/peermanager/peer_manager.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/waku/v2/peermanager/peer_manager.go b/waku/v2/peermanager/peer_manager.go index 3126f9142..1cfc5484f 100644 --- a/waku/v2/peermanager/peer_manager.go +++ b/waku/v2/peermanager/peer_manager.go @@ -313,8 +313,10 @@ func (pm *PeerManager) ensureMinRelayConnsPerTopic() { // peers. This will ensure that the peers returned by this function // match those peers that are currently connected - curPeerLen := pm.checkAndUpdateTopicHealth(topicInst) - if curPeerLen < pm.OutPeersTarget { + meshPeerLen := pm.checkAndUpdateTopicHealth(topicInst) + topicPeers := pm.host.Peerstore().(wps.WakuPeerstore).PeersByPubSubTopic(topicStr) + curPeerLen := topicPeers.Len() + if meshPeerLen < waku_proto.GossipSubDMin || curPeerLen < pm.OutPeersTarget { pm.logger.Debug("subscribed topic has not reached target peers, initiating more connections to maintain healthy mesh", zap.String("pubSubTopic", topicStr), zap.Int("connectedPeerCount", curPeerLen), zap.Int("targetPeers", pm.OutPeersTarget))