From d762d675c4aabf46805dc928284be9e78a6d5b62 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 4 Feb 2022 12:44:47 -0300 Subject: [PATCH] closest peer is only ready when it was contacted and isn't known to be bad --- lbry/dht/protocol/iterative_find.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lbry/dht/protocol/iterative_find.py b/lbry/dht/protocol/iterative_find.py index 117755797..57d39ff7d 100644 --- a/lbry/dht/protocol/iterative_find.py +++ b/lbry/dht/protocol/iterative_find.py @@ -111,6 +111,12 @@ class IterativeFinder: # seed nodes self._schedule_probe(peer) + @property + def is_closest_peer_ready(self): + if not self.closest_peer or not self.prev_closest_peer: + return False + return self.closest_peer in self.contacted and self.peer_manager.peer_is_good(self.closest_peer) is not False + async def send_probe(self, peer: 'KademliaPeer') -> FindResponse: """ Send the rpc request to the peer and return an object with the FindResponse interface @@ -308,7 +314,7 @@ class IterativeNodeFinder(IterativeFinder): # log.info("improving, %i %i %i %i %i", len(self.shortlist), len(self.active), len(self.contacted), # self.bottom_out_count, self.iteration_count) self.bottom_out_count = 0 - elif self.prev_closest_peer and self.closest_peer: + elif self.is_closest_peer_ready: self.bottom_out_count += 1 log.info("bottom out %i %i %i", len(self.active), len(self.contacted), self.bottom_out_count) if self.bottom_out_count >= self.bottom_out_limit or self.iteration_count >= self.bottom_out_limit: @@ -379,7 +385,7 @@ class IterativeValueFinder(IterativeFinder): # log.info("enough blob peers found") # if not self.finished.is_set(): # self.finished.set() - elif self.prev_closest_peer and self.closest_peer: + elif self.is_closest_peer_ready: self.bottom_out_count += 1 if self.bottom_out_count >= self.bottom_out_limit: log.info("blob peer search bottomed out")