From fd1f318b0cf7fed774cfd5f593a7da62093a8709 Mon Sep 17 00:00:00 2001 From: NIC619 Date: Thu, 18 Jul 2019 22:40:05 +0800 Subject: [PATCH] Fix: in mesh heartbeat, select from gossipsub peers subscribed to the topic --- libp2p/pubsub/gossipsub.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libp2p/pubsub/gossipsub.py b/libp2p/pubsub/gossipsub.py index 39bd8e3..6cf4380 100644 --- a/libp2p/pubsub/gossipsub.py +++ b/libp2p/pubsub/gossipsub.py @@ -267,10 +267,12 @@ class GossipSub(IPubsubRouter): num_mesh_peers_in_topic = len(self.mesh[topic]) if num_mesh_peers_in_topic < self.degree_low: + gossipsub_peers_in_topic = [peer for peer in self.pubsub.peer_topics[topic] + if peer in self.peers_gossipsub] # Select D - |mesh[topic]| peers from peers.gossipsub[topic] - mesh[topic] selected_peers = GossipSub.select_from_minus(self.degree - num_mesh_peers_in_topic, - self.peers_gossipsub, self.mesh[topic]) + gossipsub_peers_in_topic, self.mesh[topic]) for peer in selected_peers: # Add peer to mesh[topic]