Added periodic data persistence for shared and standalone instances

This commit is contained in:
Mark Qvist 2022-09-13 20:17:25 +02:00
parent 9775893840
commit 75e32af1c5
3 changed files with 43 additions and 22 deletions

View file

@ -139,7 +139,7 @@ class Identity:
if not destination_hash in Identity.known_destinations:
Identity.known_destinations[destination_hash] = storage_known_destinations[destination_hash]
RNS.log("Saving known destinations to storage...", RNS.LOG_VERBOSE)
RNS.log("Saving "+str(len(Identity.known_destinations))+" known destinations to storage...", RNS.LOG_VERBOSE)
file = open(RNS.Reticulum.storagepath+"/known_destinations","wb")
umsgpack.dump(Identity.known_destinations, file)
file.close()
@ -246,9 +246,14 @@ class Identity:
RNS.log("Error occurred while validating announce. The contained exception was: "+str(e), RNS.LOG_ERROR)
return False
@staticmethod
def persist_data():
if not RNS.Transport.owner.is_connected_to_shared_instance:
Identity.save_known_destinations()
@staticmethod
def exit_handler():
Identity.save_known_destinations()
Identity.persist_data()
@staticmethod