diff --git a/minode/main.py b/minode/main.py index 3115a36..9100206 100644 --- a/minode/main.py +++ b/minode/main.py @@ -300,18 +300,6 @@ def main(): # so we can collect I2P destination objects start_i2p_listener() - for vector in set(shared.objects): - if not shared.objects[vector].is_valid(): - if shared.objects[vector].is_expired(): - logging.debug( - 'Deleted expired object: %s', - base64.b16encode(vector).decode()) - else: - logging.warning( - 'Deleted invalid object: %s', - base64.b16encode(vector).decode()) - del shared.objects[vector] - manager = Manager() manager.start() diff --git a/minode/manager.py b/minode/manager.py index 8a1440f..6743a3a 100644 --- a/minode/manager.py +++ b/minode/manager.py @@ -28,6 +28,7 @@ class Manager(threading.Thread): time.time() - 50 * 60 + random.uniform(-1, 1) * 300 # nosec def run(self): + self.clean_objects() while True: time.sleep(0.8) now = time.time() @@ -53,12 +54,17 @@ class Manager(threading.Thread): @staticmethod def clean_objects(): for vector in set(shared.objects): - if shared.objects[vector].is_expired(): + if not shared.objects[vector].is_valid(): + if shared.objects[vector].is_expired(): + logging.debug( + 'Deleted expired object: %s', + base64.b16encode(vector).decode()) + else: + logging.warning( + 'Deleted invalid object: %s', + base64.b16encode(vector).decode()) with shared.objects_lock: del shared.objects[vector] - logging.debug( - 'Deleted expired object: %s', - base64.b16encode(vector).decode()) @staticmethod def manage_connections():