From 44aaccb7a4dda7366ae6227d4da728f17d393e86 Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Mon, 27 Mar 2023 07:58:38 +0300 Subject: [PATCH] Make a session-wide set of junk vectors to not request repeatedly --- minode/connection.py | 3 +++ minode/shared.py | 1 + 2 files changed, 4 insertions(+) diff --git a/minode/connection.py b/minode/connection.py index 2cf57e0..3858389 100644 --- a/minode/connection.py +++ b/minode/connection.py @@ -384,6 +384,7 @@ class Connection(threading.Thread): logging.debug('%s:%s -> %s', self.host_print, self.port, inv) to_get = inv.vectors.copy() to_get.difference_update(shared.objects.keys()) + to_get.difference_update(shared.junk_vectors) self.vectors_to_get.update(to_get) # Do not send objects they already have. self.vectors_to_send.difference_update(inv.vectors) @@ -395,6 +396,8 @@ class Connection(threading.Thread): self.vectors_to_get.discard(obj.vector) if obj.is_valid() and obj.vector not in shared.objects: with shared.objects_lock: + if obj.is_junk(): + return shared.junk_vectors.add(obj.vector) shared.objects[obj.vector] = obj if ( obj.object_type == shared.i2p_dest_obj_type diff --git a/minode/shared.py b/minode/shared.py index 8c6a7d6..7e2f358 100644 --- a/minode/shared.py +++ b/minode/shared.py @@ -65,4 +65,5 @@ outgoing_connections = 8 connection_limit = 250 objects = {} +junk_vectors = set() objects_lock = threading.Lock()