Apply PR feedback:

Only use pop method if graceful failure handling is desired
This commit is contained in:
NIC619
2019-11-21 14:48:03 +08:00
parent 19907e18ec
commit 501eef59de
3 changed files with 6 additions and 4 deletions

View File

@ -353,8 +353,8 @@ 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.pop(topic, None)
self.time_since_last_publish.pop(topic, None)
del self.fanout[topic]
del self.time_since_last_publish[topic]
else:
num_fanout_peers_in_topic = len(self.fanout[topic])

View File

@ -298,7 +298,7 @@ class Pubsub:
def _handle_dead_peer(self, peer_id: ID) -> None:
if peer_id not in self.peers:
return
self.peers.pop(peer_id, None)
del self.peers[peer_id]
for topic in self.peer_topics:
if peer_id in self.peer_topics[topic]: