mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-12 16:10:57 +00:00
Add check to prevent gossipsub re-join and re-leave
This commit is contained in:
@ -179,8 +179,9 @@ class GossipSub(IPubsubRouter):
|
|||||||
subscription announcement
|
subscription announcement
|
||||||
:param topic: topic to join
|
:param topic: topic to join
|
||||||
"""
|
"""
|
||||||
|
if topic in self.mesh:
|
||||||
|
return
|
||||||
# Create mesh[topic] if it does not yet exist
|
# Create mesh[topic] if it does not yet exist
|
||||||
if topic not in self.mesh:
|
|
||||||
self.mesh[topic] = []
|
self.mesh[topic] = []
|
||||||
|
|
||||||
if topic in self.fanout and len(self.fanout[topic]) == self.degree:
|
if topic in self.fanout and len(self.fanout[topic]) == self.degree:
|
||||||
@ -228,6 +229,8 @@ class GossipSub(IPubsubRouter):
|
|||||||
It is invoked after the unsubscription announcement.
|
It is invoked after the unsubscription announcement.
|
||||||
:param topic: topic to leave
|
:param topic: topic to leave
|
||||||
"""
|
"""
|
||||||
|
if topic not in self.mesh:
|
||||||
|
return
|
||||||
# Notify the peers in mesh[topic] with a PRUNE(topic) message
|
# Notify the peers in mesh[topic] with a PRUNE(topic) message
|
||||||
for peer in self.mesh[topic]:
|
for peer in self.mesh[topic]:
|
||||||
await self.emit_prune(topic, peer)
|
await self.emit_prune(topic, peer)
|
||||||
|
|||||||
Reference in New Issue
Block a user