From 89347be5265fe5bc83ea900d40f9b5adbdee39e5 Mon Sep 17 00:00:00 2001 From: NIC619 Date: Thu, 18 Jul 2019 13:26:31 +0800 Subject: [PATCH] Prevent self re-unsubscription --- libp2p/pubsub/pubsub.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libp2p/pubsub/pubsub.py b/libp2p/pubsub/pubsub.py index 07008ca..f80ed97 100644 --- a/libp2p/pubsub/pubsub.py +++ b/libp2p/pubsub/pubsub.py @@ -238,9 +238,11 @@ class Pubsub(): :param topic_id: topic_id to unsubscribe from """ + # Return if we already unsubscribed from the topic + if topic_id not in self.my_topics: + return # Remove topic_id from map if present - if topic_id in self.my_topics: - del self.my_topics[topic_id] + del self.my_topics[topic_id] # Create unsubscribe message packet = rpc_pb2.RPC()