From 01cdd11c4ed3ba2d47bd7f2d9b88c8fb86152112 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Sun, 2 Aug 2020 12:00:23 -0600 Subject: [PATCH] don't send empty messages --- libp2p/protocols/pubsub/gossipsub.nim | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libp2p/protocols/pubsub/gossipsub.nim b/libp2p/protocols/pubsub/gossipsub.nim index e432e1d27d..9b3d0e4a57 100644 --- a/libp2p/protocols/pubsub/gossipsub.nim +++ b/libp2p/protocols/pubsub/gossipsub.nim @@ -189,16 +189,14 @@ proc getGossipPeers(g: GossipSub): Table[string, ControlMessage] {.gcsafe.} = let gossipPeers = mesh + fanout let mids = g.mcache.window(topic) - if mids.len <= 0: + if not mids.len > 0: continue - let ihave = ControlIHave(topicID: topic, - messageIDs: toSeq(mids)) - if topic notin g.gossipsub: trace "topic not in gossip array, skipping", topicID = topic continue + let ihave = ControlIHave(topicID: topic, messageIDs: toSeq(mids)) for peer in allPeers: if result.len >= GossipSubD: trace "got gossip peers", peers = result.len @@ -436,8 +434,9 @@ method rpcHandler*(g: GossipSub, let messages = g.handleIWant(peer, control.iwant) if respControl.graft.len > 0 or respControl.prune.len > 0 or - respControl.ihave.len > 0 or respControl.iwant.len > 0: + respControl.ihave.len > 0: try: + info "sending control message", msg = respControl await peer.send( RPCMsg(control: some(respControl), messages: messages)) except CancelledError as exc: