Check peer id exist in dict before access

This commit is contained in:
NIC619
2019-12-17 18:47:58 +08:00
parent f10e3099cb
commit 009df257bc
2 changed files with 11 additions and 0 deletions

View File

@ -89,6 +89,8 @@ class FloodSub(IPubsubRouter):
logger.debug("publishing message %s", pubsub_msg)
for peer_id in peers_gen:
if peer_id not in self.pubsub.peers:
continue
stream = self.pubsub.peers[peer_id]
# FIXME: We should add a `WriteMsg` similar to write delimited messages.
# Ref: https://github.com/libp2p/go-libp2p-pubsub/blob/master/comm.go#L107