Reduce number of simultaneous bootstrappers, refill the bootstrap pool
This commit is contained in:
parent
72e7100a75
commit
e231755273
|
@ -29,11 +29,14 @@ class Manager(threading.Thread):
|
|||
self.last_published_i2p_destination = \
|
||||
time.time() - 50 * 60 + random.uniform(-1, 1) * 300 # nosec B311
|
||||
|
||||
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.load_data()
|
||||
self.clean_objects()
|
||||
self.bootstrap_pool = list(shared.core_nodes.union(shared.node_pool))
|
||||
random.shuffle(self.bootstrap_pool)
|
||||
self.fill_bootstrap_pool()
|
||||
while True:
|
||||
time.sleep(0.8)
|
||||
now = time.time()
|
||||
|
@ -111,20 +114,24 @@ class Manager(threading.Thread):
|
|||
):
|
||||
|
||||
if shared.ip_enabled:
|
||||
if shared.unchecked_node_pool:
|
||||
if len(shared.unchecked_node_pool) > 16:
|
||||
to_connect.update(random.sample(
|
||||
tuple(shared.unchecked_node_pool), 16))
|
||||
else:
|
||||
to_connect.update(shared.unchecked_node_pool)
|
||||
if outgoing_connections < shared.outgoing_connections / 2:
|
||||
try:
|
||||
bootstrap()
|
||||
except IndexError:
|
||||
logging.warning(
|
||||
'Ran out of bootstrap nodes, refilling')
|
||||
self.fill_bootstrap_pool()
|
||||
shared.unchecked_node_pool.difference_update(to_connect)
|
||||
if len(shared.node_pool) > 8:
|
||||
to_connect.update(random.sample(
|
||||
tuple(shared.node_pool), 8))
|
||||
else:
|
||||
to_connect.update(shared.node_pool)
|
||||
else:
|
||||
bootstrap()
|
||||
|
||||
if shared.i2p_enabled:
|
||||
if len(shared.i2p_unchecked_node_pool) > 16:
|
||||
|
|
Loading…
Reference in New Issue
Block a user