From f25d97fbd3e70e394c6328f2e847d7a26b7c0f91 Mon Sep 17 00:00:00 2001 From: NIC619 Date: Mon, 15 Jul 2019 16:32:05 +0800 Subject: [PATCH] Prevent self re-subscription --- libp2p/pubsub/pubsub.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libp2p/pubsub/pubsub.py b/libp2p/pubsub/pubsub.py index 3e8f74c..07008ca 100644 --- a/libp2p/pubsub/pubsub.py +++ b/libp2p/pubsub/pubsub.py @@ -209,6 +209,10 @@ class Pubsub(): :param topic_id: topic_id to subscribe to """ + # Already subscribed + if topic_id in self.my_topics: + return self.my_topics[topic_id] + # Map topic_id to blocking queue self.my_topics[topic_id] = asyncio.Queue()