From 34c2fbeb16a35dc875857aee56e7d2a739cc56d6 Mon Sep 17 00:00:00 2001 From: Giovanni Petrantoni <7008900+sinkingsugar@users.noreply.github.com> Date: Wed, 3 Mar 2021 08:41:21 +0000 Subject: [PATCH] small gossipsub metrics change --- libp2p/protocols/pubsub/gossipsub/behavior.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libp2p/protocols/pubsub/gossipsub/behavior.nim b/libp2p/protocols/pubsub/gossipsub/behavior.nim index 2e431c9..580d834 100644 --- a/libp2p/protocols/pubsub/gossipsub/behavior.nim +++ b/libp2p/protocols/pubsub/gossipsub/behavior.nim @@ -302,16 +302,16 @@ proc rebalanceMesh*(g: GossipSub, topic: string, metrics: ptr MeshMetrics = nil) trace "grafting", grafting = candidates.len - if candidates.len == 0: - if not isNil(metrics): - inc metrics[].noPeersTopics - else: + if candidates.len > 0: for peer in candidates: if g.mesh.addPeer(topic, peer): g.grafted(peer, topic) g.fanout.removePeer(topic, peer) grafts &= peer + if not isNil(metrics) and g.mesh.peers(topic) == 0: + inc metrics[].noPeersTopics + else: var meshPeers = toSeq(g.mesh.getOrDefault(topic, initHashSet[PubSubPeer]())) meshPeers.keepIf do (x: PubSubPeer) -> bool: x.outbound