don't probe peers too far from the top closest

This commit is contained in:
Victor Shyba 2022-02-08 19:58:28 -03:00
parent 5c60c09fef
commit 068f46d137

View file

@ -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