fixed fanout_heartbeat bug and gossipsub join test

This commit is contained in:
Mystical
2025-06-05 13:39:07 +05:30
parent 338672214c
commit cef217358f
2 changed files with 21 additions and 16 deletions

View File

@ -519,9 +519,11 @@ class GossipSub(IPubsubRouter, Service):
def fanout_heartbeat(self) -> None:
# Note: the comments here are the exact pseudocode from the spec
for topic in list(self.fanout):
if topic not in self.pubsub.peer_topics or self.time_since_last_publish.get(
topic, 0
) + self.time_to_live < int(time.time()):
if (
topic not in self.pubsub.peer_topics
and self.time_since_last_publish.get(topic, 0) + self.time_to_live
< int(time.time())
):
# Remove topic from fanout
del self.fanout[topic]
else: