From 5e79d3ab9c286ef6bc88049f3eaadd8b1ac02726 Mon Sep 17 00:00:00 2001 From: Giovanni Petrantoni Date: Sun, 20 Dec 2020 17:08:03 +0900 Subject: [PATCH] avoid triggering unsubscribeAll from unsubscribe (gossip) --- libp2p/protocols/pubsub/gossipsub.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libp2p/protocols/pubsub/gossipsub.nim b/libp2p/protocols/pubsub/gossipsub.nim index e8431940c..5f74879c7 100644 --- a/libp2p/protocols/pubsub/gossipsub.nim +++ b/libp2p/protocols/pubsub/gossipsub.nim @@ -1251,7 +1251,7 @@ method subscribe*(g: GossipSub, g.rebalanceMesh(topic) -method unsubscribeAll*(g: GossipSub, topic: string) = +proc unsubscribe*(g: GossipSub, topic: string) = var msg = RPCMsg.withSubs(@[topic], subscribe = false) gpeers = g.gossipsub.getOrDefault(topic) @@ -1281,6 +1281,8 @@ method unsubscribeAll*(g: GossipSub, topic: string) = else: g.broadcast(toSeq(gpeers), msg) +method unsubscribeAll*(g: GossipSub, topic: string) = + g.unsubscribe(topic) # finally let's remove from g.topics, do that by calling PubSub procCall PubSub(g).unsubscribeAll(topic) @@ -1292,7 +1294,7 @@ method unsubscribe*(g: GossipSub, # delete from mesh only if no handlers are left # (handlers are removed in pubsub unsubscribe above) if topic notin g.topics: - g.unsubscribeAll(topic) + g.unsubscribe(topic) method publish*(g: GossipSub, topic: string,