Prevent re-adding peers to mesh
This commit is contained in:
parent
42093e40ec
commit
99252e49f8
|
@ -204,8 +204,9 @@ class GossipSub(IPubsubRouter):
|
||||||
|
|
||||||
# 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:
|
||||||
self.mesh[topic].append(peer)
|
if peer not in self.mesh[topic]:
|
||||||
await self.emit_graft(topic, peer)
|
self.mesh[topic].append(peer)
|
||||||
|
await self.emit_graft(topic, peer)
|
||||||
|
|
||||||
if topic_in_fanout:
|
if topic_in_fanout:
|
||||||
del self.fanout[topic]
|
del self.fanout[topic]
|
||||||
|
@ -281,7 +282,12 @@ class GossipSub(IPubsubRouter):
|
||||||
self.mesh[topic]
|
self.mesh[topic]
|
||||||
)
|
)
|
||||||
|
|
||||||
for peer in selected_peers:
|
fanout_peers_not_in_mesh = [
|
||||||
|
peer
|
||||||
|
for peer in selected_peers
|
||||||
|
if peer not in self.mesh[topic]
|
||||||
|
]
|
||||||
|
for peer in fanout_peers_not_in_mesh:
|
||||||
# Add peer to mesh[topic]
|
# Add peer to mesh[topic]
|
||||||
self.mesh[topic].append(peer)
|
self.mesh[topic].append(peer)
|
||||||
|
|
||||||
|
@ -460,7 +466,8 @@ class GossipSub(IPubsubRouter):
|
||||||
|
|
||||||
# Add peer to mesh for topic
|
# Add peer to mesh for topic
|
||||||
if topic in self.mesh:
|
if topic in self.mesh:
|
||||||
self.mesh[topic].append(from_id_str)
|
if from_id_str not in self.mesh[topic]:
|
||||||
|
self.mesh[topic].append(from_id_str)
|
||||||
else:
|
else:
|
||||||
# Respond with PRUNE if not subscribed to the topic
|
# Respond with PRUNE if not subscribed to the topic
|
||||||
await self.emit_prune(topic, sender_peer_id)
|
await self.emit_prune(topic, sender_peer_id)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user