Remove unneccessary check in gossip heartbeat

This commit is contained in:
NIC619 2019-12-03 15:03:06 +08:00
parent 920cf646ef
commit ab1500c708
No known key found for this signature in database
GPG Key ID: 570C35F5C2D51B17

View File

@ -396,13 +396,12 @@ class GossipSub(IPubsubRouter):
if topic in self.pubsub.peer_topics: if topic in self.pubsub.peer_topics:
# Select D peers from peers.gossipsub[topic] # Select D peers from peers.gossipsub[topic]
peers_to_emit_ihave_to = self._get_in_topic_gossipsub_peers_from_minus( 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: for peer in peers_to_emit_ihave_to:
if peer not in self.mesh[topic]: await self.emit_ihave(topic, msg_id_strs, peer)
msg_id_strs = [str(msg_id) for msg_id in msg_ids]
await self.emit_ihave(topic, msg_id_strs, peer)
# TODO: Refactor and Dedup. This section is the roughly the same as the above. # 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 # 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: if topic in self.pubsub.peer_topics:
# Select D peers from peers.gossipsub[topic] # Select D peers from peers.gossipsub[topic]
peers_to_emit_ihave_to = self._get_in_topic_gossipsub_peers_from_minus( 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: for peer in peers_to_emit_ihave_to:
if peer not in self.fanout[topic]: await self.emit_ihave(topic, msg_id_strs, peer)
msg_id_strs = [str(msg) for msg in msg_ids]
await self.emit_ihave(topic, msg_id_strs, peer)
self.mcache.shift() self.mcache.shift()