From 7b32e2ff7cd348b064b7f6d2434aa8df749370d2 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 7 Nov 2018 18:35:00 -0500 Subject: [PATCH] don't block the dht component on populating the routing table --- lbrynet/dht/node.py | 9 ++++++--- lbrynet/extras/daemon/Components.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lbrynet/dht/node.py b/lbrynet/dht/node.py index eb929803a..793e46b76 100644 --- a/lbrynet/dht/node.py +++ b/lbrynet/dht/node.py @@ -246,7 +246,7 @@ class Node(MockKademliaHelper): yield _iterative_join() @defer.inlineCallbacks - def start(self, known_node_addresses=None): + def start(self, known_node_addresses=None, block_on_join=False): """ Causes the Node to attempt to join the DHT network by contacting the known DHT nodes. This can be called multiple times if the previous attempt has failed or if the Node has lost all the contacts. @@ -261,8 +261,11 @@ class Node(MockKademliaHelper): self.start_listening() yield self._protocol._listening # TODO: Refresh all k-buckets further away than this node's closest neighbour - yield self.joinNetwork(known_node_addresses or []) - self.start_looping_calls() + d = self.joinNetwork(known_node_addresses or []) + d.addCallback(lambda _: self.start_looping_calls()) + d.addCallback(lambda _: log.info("Joined the dht")) + if block_on_join: + yield d def start_looping_calls(self): self.safe_start_looping_call(self._change_token_lc, constants.tokenSecretChangeInterval) diff --git a/lbrynet/extras/daemon/Components.py b/lbrynet/extras/daemon/Components.py index 8ba078eef..15158c3ae 100644 --- a/lbrynet/extras/daemon/Components.py +++ b/lbrynet/extras/daemon/Components.py @@ -441,7 +441,7 @@ class DHTComponent(Component): peerPort=self.external_peer_port ) - yield self.dht_node.start(GCS('known_dht_nodes')) + yield self.dht_node.start(GCS('known_dht_nodes'), block_on_join=False) log.info("Started the dht") @defer.inlineCallbacks