mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-11-19 14:36:34 -05:00
Cleanup
This commit is contained in:
parent
1d9067c3bd
commit
c4ed59be2c
2 changed files with 17 additions and 20 deletions
|
|
@ -248,6 +248,12 @@ class KnownDestinationsStore:
|
|||
def __create_schema(self):
|
||||
db_version = self._conn.execute("PRAGMA user_version").fetchone()[0]
|
||||
|
||||
# Pre-release database cleanup
|
||||
# TODO: Remove this in 1.6.1
|
||||
if db_version > 0:
|
||||
RNS.log(f"Pre-release database detected, rebuilding known destinations DB to release format", RNS.LOG_WARNING)
|
||||
self._conn.execute("DROP TABLE IF EXISTS known_destinations")
|
||||
|
||||
self._conn.execute("""CREATE TABLE IF NOT EXISTS known_destinations (
|
||||
destination_hash BLOB PRIMARY KEY,
|
||||
last_heard REAL NOT NULL,
|
||||
|
|
@ -265,23 +271,17 @@ class KnownDestinationsStore:
|
|||
ratchet BLOB NOT NULL,
|
||||
received REAL NOT NULL)""")
|
||||
|
||||
# Pre-release migrations
|
||||
# Will be folded into finalized schema before 1.6.0 release
|
||||
# Schema migrations
|
||||
try:
|
||||
self._conn.execute("BEGIN")
|
||||
if 0 < db_version < 2: self._conn.execute("ALTER TABLE known_destinations ADD COLUMN lr_cost REAL")
|
||||
if 0 < db_version < 3: self._conn.execute("ALTER TABLE known_destinations ALTER COLUMN packet_hash DROP NOT NULL")
|
||||
self._conn.execute("PRAGMA user_version = 3")
|
||||
# No migrations yet
|
||||
self._conn.execute("PRAGMA user_version = 0")
|
||||
self._conn.execute("COMMIT")
|
||||
self._conn.commit()
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Pre-release database migration failed: {e}", RNS.LOG_CRITICAL)
|
||||
RNS.log(f"You will need to remove the known_destinations.db* files from your storage directory", RNS.LOG_CRITICAL)
|
||||
RNS.log(f"On the next instance start, the database will be rebuilt", RNS.LOG_CRITICAL)
|
||||
RNS.log(f"Exiting now", RNS.LOG_CRITICAL)
|
||||
time.sleep(1)
|
||||
RNS.panic()
|
||||
RNS.log(f"Known destinations database version migration failed: {e}", RNS.LOG_CRITICAL)
|
||||
RNS.log(f"You will need to remove the known_destinations.db* files from your storage directory so it can be rebuilt", RNS.LOG_CRITICAL)
|
||||
|
||||
def __entry_row(self, destination_hash, entry):
|
||||
stamp = entry[5] if len(entry) > 5 else None
|
||||
|
|
|
|||
|
|
@ -564,15 +564,12 @@ class Transport:
|
|||
random_blobs, receiving_interface,
|
||||
announce_packet.packet_hash, used]
|
||||
|
||||
RNS.log("Loaded path table entry for "+RNS.prettyhexrep(destination_hash)+" from storage", RNS.LOG_PATHING) if RNS.sl(RNS.LOG_PATHING) else None
|
||||
RNS.log(f"Loaded path table entry for {RNS.prettyhexrep(destination_hash)} from storage", RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
|
||||
else:
|
||||
RNS.log("Could not reconstruct path table entry from storage for "+RNS.prettyhexrep(destination_hash), RNS.LOG_PATHING) if RNS.sl(RNS.LOG_PATHING) else None
|
||||
if announce_packet == None:
|
||||
RNS.log("The announce packet could not be loaded from cache", RNS.LOG_PATHING) if RNS.sl(RNS.LOG_PATHING) else None
|
||||
if receiving_interface == None:
|
||||
RNS.log("The interface is no longer available", RNS.LOG_PATHING) if RNS.sl(RNS.LOG_PATHING) else None
|
||||
if blackholed:
|
||||
RNS.log("The associated identity is blackholed", RNS.LOG_PATHING) if RNS.sl(RNS.LOG_PATHING) else None
|
||||
RNS.log(f"Could not reconstruct path table entry from storage for {RNS.prettyhexrep(destination_hash)}", RNS.LOG_PATHING) if RNS.sl(RNS.LOG_PATHING) else None
|
||||
if announce_packet == None: RNS.log("The announce packet could not be loaded from cache", RNS.LOG_PATHING) if RNS.sl(RNS.LOG_PATHING) else None
|
||||
if receiving_interface == None: RNS.log("The interface is no longer available", RNS.LOG_PATHING) if RNS.sl(RNS.LOG_PATHING) else None
|
||||
if blackholed: RNS.log("The associated identity is blackholed", RNS.LOG_PATHING) if RNS.sl(RNS.LOG_PATHING) else None
|
||||
|
||||
if len(Transport.path_table) == 1: specifier = "entry"
|
||||
else: specifier = "entries"
|
||||
|
|
@ -1435,7 +1432,7 @@ class Transport:
|
|||
with Transport.stamper_thread_lock:
|
||||
if Transport.stamper_thread == None or not Transport.stamper_thread.is_alive():
|
||||
Transport.stamper_thread = threading.Thread(target=Transport.stamper_job, daemon=True)
|
||||
RNS.log("Starting announce stamper worker", RNS.LOG_DEBUG)
|
||||
RNS.log("Starting stamp worker", RNS.LOG_DEBUG)
|
||||
Transport.stamper_thread.start()
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue