mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-11 23:51:07 +00:00
Fix list deletion and add list remove check
This commit is contained in:
@ -460,9 +460,12 @@ class GossipSub(IPubsubRouter):
|
|||||||
else:
|
else:
|
||||||
# Check whether our peers are still in the topic
|
# Check whether our peers are still in the topic
|
||||||
# ref: https://github.com/libp2p/go-libp2p-pubsub/blob/01b9825fbee1848751d90a8469e3f5f43bac8466/gossipsub.go#L498-L504 # noqa: E501
|
# ref: https://github.com/libp2p/go-libp2p-pubsub/blob/01b9825fbee1848751d90a8469e3f5f43bac8466/gossipsub.go#L498-L504 # noqa: E501
|
||||||
for peer in self.fanout[topic]:
|
in_topic_fanout_peers = [
|
||||||
if peer not in self.pubsub.peer_topics[topic]:
|
peer
|
||||||
self.fanout[topic].remove(peer)
|
for peer in self.fanout[topic]
|
||||||
|
if peer in self.pubsub.peer_topics[topic]
|
||||||
|
]
|
||||||
|
self.fanout[topic] = in_topic_fanout_peers
|
||||||
num_fanout_peers_in_topic = len(self.fanout[topic])
|
num_fanout_peers_in_topic = len(self.fanout[topic])
|
||||||
|
|
||||||
# If |fanout[topic]| < D
|
# If |fanout[topic]| < D
|
||||||
@ -644,7 +647,10 @@ class GossipSub(IPubsubRouter):
|
|||||||
|
|
||||||
# Remove peer from mesh for topic, if peer is in topic
|
# Remove peer from mesh for topic, if peer is in topic
|
||||||
if topic in self.mesh and sender_peer_id in self.mesh[topic]:
|
if topic in self.mesh and sender_peer_id in self.mesh[topic]:
|
||||||
self.mesh[topic].remove(sender_peer_id)
|
if len(self.mesh[topic]) == 1:
|
||||||
|
del self.mesh[topic]
|
||||||
|
else:
|
||||||
|
self.mesh[topic].remove(sender_peer_id)
|
||||||
|
|
||||||
# RPC emitters
|
# RPC emitters
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user