Fix: should not remove topic if no peers

This commit is contained in:
NIC619
2019-12-03 23:10:47 +08:00
parent a9abf1e3dd
commit c08b2375e1
2 changed files with 5 additions and 20 deletions

View File

@ -317,10 +317,7 @@ class Pubsub:
for topic in self.peer_topics:
if peer_id in self.peer_topics[topic]:
# Delete the entry if no other peers left
if len(self.peer_topics[topic]) == 1:
del self.peer_topics[topic]
else:
self.peer_topics[topic].remove(peer_id)
self.peer_topics[topic].remove(peer_id)
self.router.remove_peer(peer_id)
@ -364,10 +361,7 @@ class Pubsub:
if sub_message.topicid in self.peer_topics:
if origin_id in self.peer_topics[sub_message.topicid]:
# Delete the entry if no other peers left
if len(self.peer_topics[sub_message.topicid]) == 1:
del self.peer_topics[sub_message.topicid]
else:
self.peer_topics[sub_message.topicid].remove(origin_id)
self.peer_topics[sub_message.topicid].remove(origin_id)
# FIXME(mhchia): Change the function name?
async def handle_talk(self, publish_message: rpc_pb2.Message) -> None: