From 67f9edb77daf0253de7223c22f13ecd25bbceb77 Mon Sep 17 00:00:00 2001 From: NIC619 Date: Mon, 22 Jul 2019 19:28:07 +0800 Subject: [PATCH] Remove fanout topic after joining the topic --- libp2p/pubsub/gossipsub.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libp2p/pubsub/gossipsub.py b/libp2p/pubsub/gossipsub.py index c29effd..e585566 100644 --- a/libp2p/pubsub/gossipsub.py +++ b/libp2p/pubsub/gossipsub.py @@ -207,7 +207,8 @@ class GossipSub(IPubsubRouter): self.mesh[topic].append(peer) await self.emit_graft(topic, peer) - # TODO: Do we remove all peers from fanout[topic]? + if topic_in_fanout: + del self.fanout[topic] async def leave(self, topic): # Note: the comments here are the near-exact algorithm description from the spec @@ -303,7 +304,7 @@ class GossipSub(IPubsubRouter): # TODO: there's no way time_since_last_publish gets set anywhere yet if self.time_since_last_publish[topic] > self.time_to_live: # Remove topic from fanout - self.fanout.remove(topic) + del self.fanout[topic] self.time_since_last_publish.remove(topic) else: num_fanout_peers_in_topic = len(self.fanout[topic])