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