Enable python 3.11 and resolve TLS issues #1

Merged
PeterSurda merged 8 commits from lee.miller/MiNode:ssl into v0.3 2024-06-25 00:49:12 +02:00
2 changed files with 20 additions and 17 deletions
Showing only changes of commit 740654b563 - Show all commits

View File

@ -266,11 +266,11 @@ class Connection(threading.Thread):
if len(shared.node_pool) > 10:
addr.update({
structure.NetAddr(1, a[0], a[1])
for a in random.sample(shared.node_pool, 10)})
for a in random.sample(tuple(shared.node_pool), 10)})
if len(shared.unchecked_node_pool) > 10:
addr.update({
structure.NetAddr(1, a[0], a[1])
for a in random.sample(shared.unchecked_node_pool, 10)})
for a in random.sample(tuple(shared.unchecked_node_pool), 10)})
if len(addr) != 0:
self.send_queue.put(message.Addr(addr))
@ -284,7 +284,7 @@ class Connection(threading.Thread):
# We limit size of inv messaged to 10000 entries
# because they might time out
# in very slow networks (I2P)
pack = random.sample(to_send, 10000)
pack = random.sample(tuple(to_send), 10000)
self.send_queue.put(message.Inv(pack))
to_send.difference_update(pack)
else:
@ -456,7 +456,7 @@ class Connection(threading.Thread):
logging.info(
'Queued %s vectors to get', len(self.vectors_to_get))
if len(self.vectors_to_get) > 64:
pack = random.sample(self.vectors_to_get, 64)
pack = random.sample(tuple(self.vectors_to_get), 64)
self.send_queue.put(message.GetData(pack))
self.vectors_requested.update({
vector: time.time() for vector in pack
@ -486,7 +486,7 @@ class Connection(threading.Thread):
logging.info(
'Preparing to send %s objects', len(self.vectors_to_send))
if len(self.vectors_to_send) > 16:
to_send = random.sample(self.vectors_to_send, 16)
to_send = random.sample(tuple(self.vectors_to_send), 16)
self.vectors_to_send.difference_update(to_send)
else:
to_send = self.vectors_to_send.copy()

View File

@ -98,24 +98,26 @@ class Manager(threading.Thread):
if shared.ip_enabled:
if len(shared.unchecked_node_pool) > 16:
to_connect.update(random.sample(
shared.unchecked_node_pool, 16))
tuple(shared.unchecked_node_pool), 16))
else:
to_connect.update(shared.unchecked_node_pool)
shared.unchecked_node_pool.difference_update(to_connect)
if len(shared.node_pool) > 8:
to_connect.update(random.sample(shared.node_pool, 8))
to_connect.update(random.sample(
tuple(shared.node_pool), 8))
else:
to_connect.update(shared.node_pool)
if shared.i2p_enabled:
if len(shared.i2p_unchecked_node_pool) > 16:
to_connect.update(
random.sample(shared.i2p_unchecked_node_pool, 16))
to_connect.update(random.sample(
tuple(shared.i2p_unchecked_node_pool), 16))
else:
to_connect.update(shared.i2p_unchecked_node_pool)
shared.i2p_unchecked_node_pool.difference_update(to_connect)
if len(shared.i2p_node_pool) > 8:
to_connect.update(random.sample(shared.i2p_node_pool, 8))
to_connect.update(random.sample(
tuple(shared.i2p_node_pool), 8))
else:
to_connect.update(shared.i2p_node_pool)
@ -214,17 +216,18 @@ class Manager(threading.Thread):
@staticmethod
def pickle_nodes():
if len(shared.node_pool) > 10000:
shared.node_pool = set(random.sample(shared.node_pool, 10000))
shared.node_pool = set(random.sample(
tuple(shared.node_pool), 10000))
if len(shared.unchecked_node_pool) > 1000:
shared.unchecked_node_pool = set(
random.sample(shared.unchecked_node_pool, 1000))
shared.unchecked_node_pool = set(random.sample(
tuple(shared.unchecked_node_pool), 1000))
if len(shared.i2p_node_pool) > 1000:
shared.i2p_node_pool = set(
random.sample(shared.i2p_node_pool, 1000))
shared.i2p_node_pool = set(random.sample(
tuple(shared.i2p_node_pool), 1000))
if len(shared.i2p_unchecked_node_pool) > 100:
shared.i2p_unchecked_node_pool = set(
random.sample(shared.i2p_unchecked_node_pool, 100))
shared.i2p_unchecked_node_pool = set(random.sample(
tuple(shared.i2p_unchecked_node_pool), 100))
try:
with open(