From 6d4523c27ee5f32e1b27a176d6a1d2ed1c70206b Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 23 Jul 2026 17:14:48 +0200 Subject: [PATCH] Added rebalanced time to links --- RNS/Link.py | 1 + RNS/Transport.py | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/RNS/Link.py b/RNS/Link.py index f9a1f8e8..09d3c44e 100644 --- a/RNS/Link.py +++ b/RNS/Link.py @@ -265,6 +265,7 @@ class Link: self.owner = owner self.destination = destination self.expected_hops = None + self.rebalanced = None self.attached_interface = None self.__remote_identity = None self.__track_phy_stats = False diff --git a/RNS/Transport.py b/RNS/Transport.py index baf4941e..54a5e319 100755 --- a/RNS/Transport.py +++ b/RNS/Transport.py @@ -2297,10 +2297,12 @@ class Transport: RNS.log(f"Re-balancing path to {RNS.prettyhexrep(link.destination.hash)} at link terminus ({link.expected_hops}->{packet.hops})", REBALANCE_LOGLEVEL) if RNS.sl(REBALANCE_LOGLEVEL) else None link.expected_hops = packet.hops with Transport.path_table_lock: - if link.destination.hash in Transport.path_table: - path_entry = Transport.path_table[link.destination.hash] - path_entry[IDX_PT_HOPS] = packet.hops - RNS.log(f"Path table re-balanced for {RNS.prettyhexrep(link.destination.hash)}", REBALANCE_LOGLEVEL) if RNS.sl(REBALANCE_LOGLEVEL) else None + if not link.rebalanced: + link.rebalanced = time.time() + if link.destination.hash in Transport.path_table: + path_entry = Transport.path_table[link.destination.hash] + path_entry[IDX_PT_HOPS] = packet.hops + RNS.log(f"Path table re-balanced for {RNS.prettyhexrep(link.destination.hash)}", REBALANCE_LOGLEVEL) if RNS.sl(REBALANCE_LOGLEVEL) else None else: RNS.log(f"Aborting path re-balancing at link terminus for {RNS.prettyhexrep(link.destination.hash)} on link {link} due to invalid signature", REBALANCE_LOGLEVEL) if RNS.sl(REBALANCE_LOGLEVEL) else None except Exception as e: RNS.log("Error while validating link request proof for path re-balancing at link terminus. The contained exception was: "+str(e), REBALANCE_LOGLEVEL) if RNS.sl(REBALANCE_LOGLEVEL) else None