From d61accea1a704ebb001bafade22e73f917af89ab Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 11 Aug 2022 21:14:56 -0300 Subject: [PATCH] simplify bucket refresh loop --- lbry/dht/protocol/routing_table.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lbry/dht/protocol/routing_table.py b/lbry/dht/protocol/routing_table.py index 516b72818..11b64b8f7 100644 --- a/lbry/dht/protocol/routing_table.py +++ b/lbry/dht/protocol/routing_table.py @@ -235,13 +235,9 @@ class TreeRoutingTable: return self.buckets[self._kbucket_index(contact_id)].get_peer(contact_id) def get_refresh_list(self, start_index: int = 0, force: bool = False) -> typing.List[bytes]: - bucket_index = start_index refresh_ids = [] - now = int(self._loop.time()) - for bucket in self.buckets[start_index:]: - to_search = self._midpoint_id_in_bucket_range(bucket_index) - refresh_ids.append(to_search) - bucket_index += 1 + for offset, _ in enumerate(self.buckets[start_index:]): + refresh_ids.append(self._midpoint_id_in_bucket_range(start_index + offset)) # if we have 3 or fewer populated buckets get two random ids in the range of each to try and # populate/split the buckets further buckets_with_contacts = self.buckets_with_contacts()