forked from LBRYCommunity/lbry-sdk
reset closest peer on failure
This commit is contained in:
parent
fb6e342043
commit
b78929f4d5
1 changed files with 8 additions and 0 deletions
|
@ -176,14 +176,22 @@ class IterativeFinder:
|
||||||
self.check_result_ready(response)
|
self.check_result_ready(response)
|
||||||
self._log_state()
|
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'):
|
async def _send_probe(self, peer: 'KademliaPeer'):
|
||||||
try:
|
try:
|
||||||
response = await self.send_probe(peer)
|
response = await self.send_probe(peer)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
|
self._reset_closest(peer)
|
||||||
self.active.discard(peer)
|
self.active.discard(peer)
|
||||||
return
|
return
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
log.warning(str(err))
|
log.warning(str(err))
|
||||||
|
self._reset_closest(peer)
|
||||||
self.active.discard(peer)
|
self.active.discard(peer)
|
||||||
return
|
return
|
||||||
except TransportNotConnected:
|
except TransportNotConnected:
|
||||||
|
|
Loading…
Reference in a new issue