mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-05 05:40:14 +00:00
Improved cache handling
This commit is contained in:
parent
5e072affe4
commit
8cff18f8ce
@ -135,8 +135,14 @@ class Identity:
|
||||
if os.path.isfile(RNS.Reticulum.storagepath+"/known_destinations"):
|
||||
try:
|
||||
file = open(RNS.Reticulum.storagepath+"/known_destinations","rb")
|
||||
Identity.known_destinations = umsgpack.load(file)
|
||||
loaded_known_destinations = umsgpack.load(file)
|
||||
file.close()
|
||||
|
||||
Identity.known_destinations = {}
|
||||
for known_destination in loaded_known_destinations:
|
||||
if len(known_destination) == RNS.Reticulum.TRUNCATED_HASHLENGTH//8:
|
||||
Identity.known_destinations[known_destination] = loaded_known_destinations[known_destination]
|
||||
|
||||
RNS.log("Loaded "+str(len(Identity.known_destinations))+" known destination from storage", RNS.LOG_VERBOSE)
|
||||
except:
|
||||
RNS.log("Error loading known destinations from disk, file will be recreated on exit", RNS.LOG_ERROR)
|
||||
|
@ -126,7 +126,7 @@ class Reticulum:
|
||||
|
||||
MDU = MTU - HEADER_MAXSIZE - IFAC_MIN_SIZE
|
||||
|
||||
CACHE_TIME = 24*60*60
|
||||
RESOURCE_CACHE = 24*60*60
|
||||
JOB_INTERVAL = 15*60
|
||||
|
||||
router = None
|
||||
@ -893,7 +893,7 @@ class Reticulum:
|
||||
filepath = self.resourcepath + "/" + filename
|
||||
mtime = os.path.getmtime(filepath)
|
||||
age = now - mtime
|
||||
if age > Reticulum.CACHE_TIME:
|
||||
if age > Reticulum.RESOURCE_CACHE:
|
||||
os.unlink(filepath)
|
||||
|
||||
except Exception as e:
|
||||
@ -906,7 +906,7 @@ class Reticulum:
|
||||
filepath = self.cachepath + "/" + filename
|
||||
mtime = os.path.getmtime(filepath)
|
||||
age = now - mtime
|
||||
if age > Reticulum.CACHE_TIME:
|
||||
if age > RNS.Transport.DESTINATION_TIMEOUT:
|
||||
os.unlink(filepath)
|
||||
|
||||
except Exception as e:
|
||||
|
@ -68,7 +68,7 @@ class Transport:
|
||||
PATH_REQUEST_RW = 2 # Path request random window
|
||||
|
||||
LINK_TIMEOUT = RNS.Link.STALE_TIME * 1.25
|
||||
REVERSE_TIMEOUT = 30*60 # Reverse table entries are removed after max 30 minutes
|
||||
REVERSE_TIMEOUT = 30*60 # Reverse table entries are removed after 30 minutes
|
||||
DESTINATION_TIMEOUT = 60*60*24*7 # Destination table entries are removed if unused for one week
|
||||
MAX_RECEIPTS = 1024 # Maximum number of receipts to keep track of
|
||||
MAX_RATE_TIMESTAMPS = 16 # Maximum number of announce timestamps to keep per destination
|
||||
@ -181,6 +181,8 @@ class Transport:
|
||||
|
||||
for serialised_entry in serialised_destinations:
|
||||
destination_hash = serialised_entry[0]
|
||||
|
||||
if len(destination_hash) == RNS.Reticulum.TRUNCATED_HASHLENGTH//8:
|
||||
timestamp = serialised_entry[1]
|
||||
received_from = serialised_entry[2]
|
||||
hops = serialised_entry[3]
|
||||
|
Loading…
Reference in New Issue
Block a user