Delete old nodes

- cleanup will delete nodes that are older than 3 days
This commit is contained in:
Peter Šurda 2016-06-15 18:45:23 +02:00
parent 65211703c0
commit ca297cafed
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
1 changed files with 12 additions and 0 deletions

View File

@ -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':
# cleanup old nodes
now = int(time.time())
toDelete = []
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]
# Let us write out the knowNodes to disk if there is anything new to write out.
if shared.needToWriteKnownNodesToDisk: