From 0672f5ae6dca04a07731fb4bedbd423619067bb2 Mon Sep 17 00:00:00 2001 From: NIC619 Date: Mon, 2 Dec 2019 16:38:48 +0800 Subject: [PATCH] Fix: move heartbeat delay to `heartbeat` --- libp2p/pubsub/gossipsub.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libp2p/pubsub/gossipsub.py b/libp2p/pubsub/gossipsub.py index ea2594e0..6d88f874 100644 --- a/libp2p/pubsub/gossipsub.py +++ b/libp2p/pubsub/gossipsub.py @@ -106,8 +106,6 @@ class GossipSub(IPubsubRouter): logger.debug("attached to pusub") # Start heartbeat now that we have a pubsub instance - # Start after a delay. Ref: https://github.com/libp2p/go-libp2p-pubsub/blob/01b9825fbee1848751d90a8469e3f5f43bac8466/gossipsub.go#L410 # Noqa: E501 - await asyncio.sleep(0.1) asyncio.ensure_future(self.heartbeat()) def add_peer(self, peer_id: ID, protocol_id: TProtocol) -> None: @@ -295,6 +293,8 @@ class GossipSub(IPubsubRouter): Note: the heartbeats are called with awaits because each heartbeat depends on the state changes in the preceding heartbeat """ + # Start after a delay. Ref: https://github.com/libp2p/go-libp2p-pubsub/blob/01b9825fbee1848751d90a8469e3f5f43bac8466/gossipsub.go#L410 # Noqa: E501 + await asyncio.sleep(0.1) while True: await self.mesh_heartbeat()