Store interface hashes instead of recomputing every time

This commit is contained in:
Mark Qvist 2026-07-20 11:49:09 +02:00
parent 2d811dc398
commit ef9244f79f
No known key found for this signature in database

View file

@ -102,6 +102,7 @@ class Interface:
self.online = False self.online = False
self.bitrate = 62500 self.bitrate = 62500
self.HW_MTU = None self.HW_MTU = None
self.__hash = None
self.supports_discovery = False self.supports_discovery = False
self.discoverable = False self.discoverable = False
@ -139,7 +140,8 @@ class Interface:
self.op_freq_deque = deque(maxlen=Interface.OA_FREQ_SAMPLES) self.op_freq_deque = deque(maxlen=Interface.OA_FREQ_SAMPLES)
def get_hash(self): 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 # This is a generic function for determining when an interface
# should activate ingress limiting. Since this can vary for # should activate ingress limiting. Since this can vary for
@ -364,11 +366,9 @@ class Interface:
@staticmethod @staticmethod
def get_config_obj(config_in): def get_config_obj(config_in):
if type(config_in) == ConfigObj: if type(config_in) == ConfigObj: return config_in
return config_in
else: else:
try: try: return ConfigObj(config_in)
return ConfigObj(config_in)
except Exception as e: except Exception as e:
RNS.log(f"Could not parse supplied configuration data. The contained exception was: {e}", RNS.LOG_ERROR) RNS.log(f"Could not parse supplied configuration data. The contained exception was: {e}", RNS.LOG_ERROR)
raise SystemError("Invalid configuration data supplied") raise SystemError("Invalid configuration data supplied")