From ab1500c7084ba377e76fa4bd97a19ad03a6922ff Mon Sep 17 00:00:00 2001 From: NIC619 Date: Tue, 3 Dec 2019 15:03:06 +0800 Subject: [PATCH] Remove unneccessary check in gossip heartbeat --- libp2p/pubsub/gossipsub.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libp2p/pubsub/gossipsub.py b/libp2p/pubsub/gossipsub.py index 831e6d3..cf48f53 100644 --- a/libp2p/pubsub/gossipsub.py +++ b/libp2p/pubsub/gossipsub.py @@ -396,13 +396,12 @@ class GossipSub(IPubsubRouter): if topic in self.pubsub.peer_topics: # Select D peers from peers.gossipsub[topic] peers_to_emit_ihave_to = self._get_in_topic_gossipsub_peers_from_minus( - topic, self.degree, [] + topic, self.degree, self.mesh[topic] ) + msg_id_strs = [str(msg_id) for msg_id in msg_ids] for peer in peers_to_emit_ihave_to: - if peer not in self.mesh[topic]: - msg_id_strs = [str(msg_id) for msg_id in msg_ids] - await self.emit_ihave(topic, msg_id_strs, peer) + await self.emit_ihave(topic, msg_id_strs, peer) # TODO: Refactor and Dedup. This section is the roughly the same as the above. # Do the same for fanout, for all topics not already hit in mesh @@ -414,12 +413,11 @@ class GossipSub(IPubsubRouter): if topic in self.pubsub.peer_topics: # Select D peers from peers.gossipsub[topic] peers_to_emit_ihave_to = self._get_in_topic_gossipsub_peers_from_minus( - topic, self.degree, [] + topic, self.degree, self.fanout[topic] ) + msg_id_strs = [str(msg) for msg in msg_ids] for peer in peers_to_emit_ihave_to: - if peer not in self.fanout[topic]: - msg_id_strs = [str(msg) for msg in msg_ids] - await self.emit_ihave(topic, msg_id_strs, peer) + await self.emit_ihave(topic, msg_id_strs, peer) self.mcache.shift()