From 766d8ba1e10c1379fadaae7bf9f9c48aaa5b4e4d Mon Sep 17 00:00:00 2001 From: mhchia Date: Sat, 27 Jul 2019 12:06:36 +0800 Subject: [PATCH] A little bit clean up --- libp2p/pubsub/gossipsub.py | 14 ++++++-------- libp2p/pubsub/pubsub.py | 3 --- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/libp2p/pubsub/gossipsub.py b/libp2p/pubsub/gossipsub.py index b65462d..d394e95 100644 --- a/libp2p/pubsub/gossipsub.py +++ b/libp2p/pubsub/gossipsub.py @@ -208,13 +208,11 @@ class GossipSub(IPubsubRouter): # in the fanout for a topic (or the topic is not in the fanout). # Selects the remaining number of peers (D-x) from peers.gossipsub[topic]. if topic in self.pubsub.peer_topics: - gossipsub_peers_in_topic = [peer for peer in self.pubsub.peer_topics[topic] - if peer in self.peers_gossipsub] - selected_peers = \ - GossipSub.select_from_minus(self.degree - fanout_size, - gossipsub_peers_in_topic, - fanout_peers) - + selected_peers = self._get_peers_from_minus( + topic, + self.degree - fanout_size, + fanout_peers, + ) # Combine fanout peers with selected peers fanout_peers += selected_peers @@ -295,7 +293,7 @@ class GossipSub(IPubsubRouter): selected_peers = GossipSub.select_from_minus( self.degree - num_mesh_peers_in_topic, gossipsub_peers_in_topic, - self.mesh[topic] + self.mesh[topic], ) fanout_peers_not_in_mesh = [ diff --git a/libp2p/pubsub/pubsub.py b/libp2p/pubsub/pubsub.py index 560b8c2..7c33d0b 100644 --- a/libp2p/pubsub/pubsub.py +++ b/libp2p/pubsub/pubsub.py @@ -313,9 +313,6 @@ class Pubsub: # Write message to stream await stream.write(rpc_msg) - def list_peers(self, topic_id: str) -> Tuple[ID, ...]: - return - async def publish(self, topic_id: str, data: bytes) -> None: """ Publish data to a topic