From b78929f4d59af2fe27f9428309a90fe366ff8d16 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 7 Feb 2022 21:46:43 -0300 Subject: [PATCH] reset closest peer on failure --- lbry/dht/protocol/iterative_find.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lbry/dht/protocol/iterative_find.py b/lbry/dht/protocol/iterative_find.py index f29f6c048..c2fc10429 100644 --- a/lbry/dht/protocol/iterative_find.py +++ b/lbry/dht/protocol/iterative_find.py @@ -176,14 +176,22 @@ class IterativeFinder: self.check_result_ready(response) self._log_state() + def _reset_closest(self, peer): + if peer == self.prev_closest_peer: + self.prev_closest_peer = None + if peer == self.closest_peer: + self.closest_peer = self.prev_closest_peer + async def _send_probe(self, peer: 'KademliaPeer'): try: response = await self.send_probe(peer) except asyncio.TimeoutError: + self._reset_closest(peer) self.active.discard(peer) return except ValueError as err: log.warning(str(err)) + self._reset_closest(peer) self.active.discard(peer) return except TransportNotConnected: