Reduce number of simultaneous bootstrappers, refill the bootstrap pool
This commit is contained in:
parent
0330346e16
commit
bb65e7f0b9
|
@ -29,11 +29,14 @@ class Manager(threading.Thread):
|
||||||
self.last_published_i2p_destination = \
|
self.last_published_i2p_destination = \
|
||||||
time.time() - 50 * 60 + random.uniform(-1, 1) * 300 # nosec B311
|
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):
|
def run(self):
|
||||||
self.load_data()
|
self.load_data()
|
||||||
self.clean_objects()
|
self.clean_objects()
|
||||||
self.bootstrap_pool = list(shared.core_nodes.union(shared.node_pool))
|
self.fill_bootstrap_pool()
|
||||||
random.shuffle(self.bootstrap_pool)
|
|
||||||
while True:
|
while True:
|
||||||
time.sleep(0.8)
|
time.sleep(0.8)
|
||||||
now = time.time()
|
now = time.time()
|
||||||
|
@ -112,20 +115,24 @@ class Manager(threading.Thread):
|
||||||
):
|
):
|
||||||
|
|
||||||
if shared.ip_enabled:
|
if shared.ip_enabled:
|
||||||
if shared.unchecked_node_pool:
|
|
||||||
if len(shared.unchecked_node_pool) > 16:
|
if len(shared.unchecked_node_pool) > 16:
|
||||||
to_connect.update(random.sample(
|
to_connect.update(random.sample(
|
||||||
tuple(shared.unchecked_node_pool), 16))
|
tuple(shared.unchecked_node_pool), 16))
|
||||||
else:
|
else:
|
||||||
to_connect.update(shared.unchecked_node_pool)
|
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)
|
shared.unchecked_node_pool.difference_update(to_connect)
|
||||||
if len(shared.node_pool) > 8:
|
if len(shared.node_pool) > 8:
|
||||||
to_connect.update(random.sample(
|
to_connect.update(random.sample(
|
||||||
tuple(shared.node_pool), 8))
|
tuple(shared.node_pool), 8))
|
||||||
else:
|
else:
|
||||||
to_connect.update(shared.node_pool)
|
to_connect.update(shared.node_pool)
|
||||||
else:
|
|
||||||
bootstrap()
|
|
||||||
|
|
||||||
if shared.i2p_enabled:
|
if shared.i2p_enabled:
|
||||||
if len(shared.i2p_unchecked_node_pool) > 16:
|
if len(shared.i2p_unchecked_node_pool) > 16:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user