Reduce number of simultaneous bootstrappers, refill the bootstrap pool

This commit is contained in:
Lee Miller 2023-08-19 05:40:10 +03:00
parent 032cfb1bab
commit 39f92fd1b2
Signed by untrusted user: lee.miller
GPG Key ID: 4F97A5EA88F4AB63
1 changed files with 12 additions and 4 deletions

View File

@ -28,10 +28,13 @@ class Manager(threading.Thread):
self.last_published_i2p_destination = \
time.time() - 50 * 60 + random.uniform(-1, 1) * 300 # nosec
def run(self):
self.clean_objects()
def fill_bootstrap_pool(self):
self.bootstrap_pool = list(shared.core_nodes.union(shared.node_pool))
random.shuffle(self.bootstrap_pool)
def run(self):
self.clean_objects()
self.fill_bootstrap_pool()
while True:
time.sleep(0.8)
now = time.time()
@ -121,8 +124,13 @@ class Manager(threading.Thread):
to_connect.update(random.sample(shared.node_pool, 8))
else:
to_connect.update(shared.node_pool)
else:
bootstrap()
elif outgoing_connections < shared.outgoing_connections / 2:
try:
bootstrap()
except IndexError:
logging.warning(
'Ran out of bootstrap nodes, refilling')
self.fill_bootstrap_pool()
if shared.i2p_enabled:
if len(shared.i2p_unchecked_node_pool) > 16: