From ef9244f79fa35ec0b25d500080fe3583c6000d8b Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 20 Jul 2026 11:49:09 +0200 Subject: [PATCH] Store interface hashes instead of recomputing every time --- RNS/Interfaces/Interface.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/RNS/Interfaces/Interface.py b/RNS/Interfaces/Interface.py index 6759ea3f..4553fba1 100755 --- a/RNS/Interfaces/Interface.py +++ b/RNS/Interfaces/Interface.py @@ -102,6 +102,7 @@ class Interface: self.online = False self.bitrate = 62500 self.HW_MTU = None + self.__hash = None self.supports_discovery = False self.discoverable = False @@ -139,7 +140,8 @@ class Interface: self.op_freq_deque = deque(maxlen=Interface.OA_FREQ_SAMPLES) def get_hash(self): - return RNS.Identity.full_hash(str(self).encode("utf-8")) + if not self.__hash: self.__hash = RNS.Identity.full_hash(str(self).encode("utf-8")) + return self.__hash # This is a generic function for determining when an interface # should activate ingress limiting. Since this can vary for @@ -364,11 +366,9 @@ class Interface: @staticmethod def get_config_obj(config_in): - if type(config_in) == ConfigObj: - return config_in + if type(config_in) == ConfigObj: return config_in else: - try: - return ConfigObj(config_in) + try: return ConfigObj(config_in) except Exception as e: RNS.log(f"Could not parse supplied configuration data. The contained exception was: {e}", RNS.LOG_ERROR) raise SystemError("Invalid configuration data supplied") \ No newline at end of file