From ca297cafed5b29e52e6390ef968f8f435cc99bdd Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Wed, 15 Jun 2016 18:45:23 +0200 Subject: [PATCH] Delete old nodes - cleanup will delete nodes that are older than 3 days --- src/class_singleCleaner.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/class_singleCleaner.py b/src/class_singleCleaner.py index 8fa8e6d1..b9e8b1a1 100644 --- a/src/class_singleCleaner.py +++ b/src/class_singleCleaner.py @@ -21,6 +21,7 @@ inventorySets (clears then reloads data out of sql database) It cleans these tables on the disk: inventory (clears expired objects) pubkeys (clears pubkeys older than 4 weeks old which we have not used personally) +knownNodes (clears addresses which have not been online for over 3 days) It resends messages when there has been no response: resends getpubkey messages in 5 days (then 10 days, then 20 days, etc...) @@ -80,6 +81,17 @@ class singleCleaner(threading.Thread, StoppableThread): elif status == 'msgsent': resendMsg(ackData) + # cleanup old nodes + now = int(time.time()) + toDelete = [] + shared.knownNodesLock.acquire() + for stream in shared.knownNodes: + for node in shared.knownNodes[stream].keys(): + if now - shared.knownNodes[stream][node] > 259200: # 3 days + shared.needToWriteKownNodesToDisk = True + del shared.knownNodes[stream][node] + shared.knownNodesLock.release() + # Let us write out the knowNodes to disk if there is anything new to write out. if shared.needToWriteKnownNodesToDisk: shared.knownNodesLock.acquire()