From 068f46d137e56d8cb58407e8478533656dbbcafe Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Tue, 8 Feb 2022 19:58:28 -0300 Subject: [PATCH] don't probe peers too far from the top closest --- lbry/dht/protocol/iterative_find.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lbry/dht/protocol/iterative_find.py b/lbry/dht/protocol/iterative_find.py index 62c13cd5d..e334c3f61 100644 --- a/lbry/dht/protocol/iterative_find.py +++ b/lbry/dht/protocol/iterative_find.py @@ -86,7 +86,7 @@ class IterativeFinder: self.key = key self.bottom_out_limit = bottom_out_limit - self.max_results = max_results + self.max_results = max(constants.K, max_results) self.exclude = exclude or [] self.active: typing.Dict['KademliaPeer', int] = {} # peer: distance, sorted @@ -229,6 +229,8 @@ class IterativeFinder: continue if added >= constants.ALPHA: break + if index > self.max_results: + break origin_address = (peer.address, peer.udp_port) if origin_address in self.exclude: continue