From a866621ccbdd2cfd423da37771c4001c68373438 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 3 Dec 2021 16:48:22 -0300 Subject: [PATCH] do not limit DHT results by K, respect max_results --- lbry/dht/protocol/iterative_find.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lbry/dht/protocol/iterative_find.py b/lbry/dht/protocol/iterative_find.py index f53b17c27..f8bd2ba6b 100644 --- a/lbry/dht/protocol/iterative_find.py +++ b/lbry/dht/protocol/iterative_find.py @@ -286,7 +286,7 @@ class IterativeNodeFinder(IterativeFinder): and self.peer_manager.peer_is_good(peer) is not False ] not_yet_yielded.sort(key=lambda peer: self.distance(peer.node_id)) - to_yield = not_yet_yielded[:min(constants.K, len(not_yet_yielded))] + to_yield = not_yet_yielded[:max(constants.K, self.max_results)] if to_yield: self.yielded_peers.update(to_yield) self.iteration_queue.put_nowait(to_yield)