FIx:
check topic exist in `pubsub.peer_topics`
This commit is contained in:
parent
2c1c8dc8cf
commit
41141c028b
|
@ -267,19 +267,20 @@ class GossipSub(IPubsubRouter):
|
||||||
|
|
||||||
num_mesh_peers_in_topic = len(self.mesh[topic])
|
num_mesh_peers_in_topic = len(self.mesh[topic])
|
||||||
if num_mesh_peers_in_topic < self.degree_low:
|
if num_mesh_peers_in_topic < self.degree_low:
|
||||||
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]
|
||||||
|
if peer in self.peers_gossipsub]
|
||||||
|
|
||||||
# Select D - |mesh[topic]| peers from peers.gossipsub[topic] - mesh[topic]
|
# Select D - |mesh[topic]| peers from peers.gossipsub[topic] - mesh[topic]
|
||||||
selected_peers = GossipSub.select_from_minus(self.degree - num_mesh_peers_in_topic,
|
selected_peers = GossipSub.select_from_minus(self.degree - num_mesh_peers_in_topic,
|
||||||
gossipsub_peers_in_topic, self.mesh[topic])
|
gossipsub_peers_in_topic, self.mesh[topic])
|
||||||
|
|
||||||
for peer in selected_peers:
|
for peer in selected_peers:
|
||||||
# Add peer to mesh[topic]
|
# Add peer to mesh[topic]
|
||||||
self.mesh[topic].append(peer)
|
self.mesh[topic].append(peer)
|
||||||
|
|
||||||
# Emit GRAFT(topic) control message to peer
|
# Emit GRAFT(topic) control message to peer
|
||||||
await self.emit_graft(topic, peer)
|
await self.emit_graft(topic, peer)
|
||||||
|
|
||||||
if num_mesh_peers_in_topic > self.degree_high:
|
if num_mesh_peers_in_topic > self.degree_high:
|
||||||
# Select |mesh[topic]| - D peers from mesh[topic]
|
# Select |mesh[topic]| - D peers from mesh[topic]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user