mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-09 14:40:53 +00:00
Fix:
prevent selecting peers from topic not in peer topics
This commit is contained in:
@ -191,15 +191,16 @@ class GossipSub(IPubsubRouter):
|
|||||||
# There are less than D peers (let this number be x)
|
# There are less than D peers (let this number be x)
|
||||||
# in the fanout for a topic (or the topic is not in the fanout).
|
# 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].
|
# Selects the remaining number of peers (D-x) from peers.gossipsub[topic].
|
||||||
gossipsub_peers_in_topic = [peer for peer in self.pubsub.peer_topics[topic]
|
if topic in self.pubsub.peer_topics:
|
||||||
if peer in self.peers_gossipsub]
|
gossipsub_peers_in_topic = [peer for peer in self.pubsub.peer_topics[topic]
|
||||||
selected_peers = \
|
if peer in self.peers_gossipsub]
|
||||||
GossipSub.select_from_minus(self.degree - fanout_size,
|
selected_peers = \
|
||||||
gossipsub_peers_in_topic,
|
GossipSub.select_from_minus(self.degree - fanout_size,
|
||||||
fanout_peers)
|
gossipsub_peers_in_topic,
|
||||||
|
fanout_peers)
|
||||||
|
|
||||||
# Combine fanout peers with selected peers
|
# Combine fanout peers with selected peers
|
||||||
fanout_peers += selected_peers
|
fanout_peers += selected_peers
|
||||||
|
|
||||||
# Add fanout peers to mesh and notifies them with a GRAFT(topic) control message.
|
# Add fanout peers to mesh and notifies them with a GRAFT(topic) control message.
|
||||||
for peer in fanout_peers:
|
for peer in fanout_peers:
|
||||||
|
|||||||
Reference in New Issue
Block a user