fix: use total peers for pubsubTopic as out peers target (#1170)

This commit is contained in:
Prem Chaitanya Prathi 2024-07-30 11:02:59 +05:30 committed by GitHub
parent a9be17fd48
commit 76d8fd687d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -313,8 +313,10 @@ func (pm *PeerManager) ensureMinRelayConnsPerTopic() {
// peers. This will ensure that the peers returned by this function // peers. This will ensure that the peers returned by this function
// match those peers that are currently connected // match those peers that are currently connected
curPeerLen := pm.checkAndUpdateTopicHealth(topicInst) meshPeerLen := pm.checkAndUpdateTopicHealth(topicInst)
if curPeerLen < pm.OutPeersTarget { 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", 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.String("pubSubTopic", topicStr), zap.Int("connectedPeerCount", curPeerLen),
zap.Int("targetPeers", pm.OutPeersTarget)) zap.Int("targetPeers", pm.OutPeersTarget))