From 40dcd7d08485a22c76f67e182d51e994394918ee Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 2 Nov 2026 21:05:20 +0100 Subject: [PATCH] Made PN peer throttle time configurable --- LXMF/LXMRouter.py | 10 ++++++---- LXMF/Utilities/lxmd.py | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/LXMF/LXMRouter.py b/LXMF/LXMRouter.py index cf21d96..016c208 100644 --- a/LXMF/LXMRouter.py +++ b/LXMF/LXMRouter.py @@ -69,7 +69,7 @@ class LXMRouter: DELIVERY_LIMIT = 1000 PR_PATH_TIMEOUT = 10 - PN_STAMP_THROTTLE = 180 + PN_STAMP_THROTTLE = 300 PR_IDLE = 0x00 PR_PATH_REQUESTED = 0x01 @@ -110,7 +110,8 @@ class LXMRouter: from_static_only=False, sync_strategy=LXMPeer.STRATEGY_PERSISTENT, propagation_cost=PROPAGATION_COST, propagation_cost_flexibility=PROPAGATION_COST_FLEX, peering_cost=PEERING_COST, max_peering_cost=MAX_PEERING_COST, max_inbound_syncs=MAX_INBOUND_SYNCS, - sequential_validation=SEQUENTIAL_VALIDATION, static_sequential=STATIC_SEQUENTIAL): + sequential_validation=SEQUENTIAL_VALIDATION, static_sequential=STATIC_SEQUENTIAL, + pn_stamp_throttle=PN_STAMP_THROTTLE): random.seed(os.urandom(10)) @@ -136,7 +137,8 @@ class LXMRouter: self.name = name self.propagation_node = False - self.propagation_node_start_time = None + self.propagation_node_start_time = None + self.pn_stamp_throttle = pn_stamp_throttle if storagepath == None: raise ValueError("LXMF cannot be initialised without a storage path") else: @@ -2586,7 +2588,7 @@ class LXMRouter: if invalid_message_count > 0: resource.link.teardown() if remote_identity != None: - throttle_time = LXMRouter.PN_STAMP_THROTTLE + throttle_time = self.pn_stamp_throttle self.throttled_peers[remote_hash] = time.time()+throttle_time ms = "" if invalid_message_count == 1 else "s" RNS.log(f"Propagation transfer from {remote_str} contained {invalid_message_count} message{ms} with invalid stamps, throttled for {RNS.prettytime(throttle_time)}", RNS.LOG_NOTICE) diff --git a/LXMF/Utilities/lxmd.py b/LXMF/Utilities/lxmd.py index 992e7f3..4a86bef 100644 --- a/LXMF/Utilities/lxmd.py +++ b/LXMF/Utilities/lxmd.py @@ -197,6 +197,13 @@ def apply_config(): else: active_configuration["propagation_stamp_cost_flexibility"] = LXMF.LXMRouter.PROPAGATION_COST_FLEX + if "propagation" in lxmd_config and "propagation_stamp_throttle" in lxmd_config["propagation"]: + active_configuration["propagation_stamp_throttle"] = lxmd_config["propagation"].as_float("propagation_stamp_throttle")*60 + if active_configuration["propagation_stamp_throttle"] < LXMF.LXMRouter.PN_STAMP_THROTTLE: + active_configuration["propagation_stamp_throttle"] = LXMF.LXMRouter.PN_STAMP_THROTTLE + else: + active_configuration["propagation_stamp_throttle"] = LXMF.LXMRouter.PN_STAMP_THROTTLE + if "propagation" in lxmd_config and "peering_cost" in lxmd_config["propagation"]: active_configuration["peering_cost"] = lxmd_config["propagation"].as_float("peering_cost") if active_configuration["peering_cost"] < 0: @@ -412,6 +419,7 @@ def program_setup(configdir = None, rnsconfigdir = None, run_pn = False, on_inbo max_peers = active_configuration["max_peers"], static_peers = active_configuration["static_peers"], from_static_only = active_configuration["from_static_only"], + pn_stamp_throttle = active_configuration["propagation_stamp_throttle"], name = active_configuration["node_name"]) message_router.register_delivery_callback(lxmf_delivery) @@ -1038,6 +1046,18 @@ autopeer_maxdepth = 6 # propagation_stamp_cost_flexibility = 3.0 +# If a peer delivers messages with stamp costs +# not conforming to this node's targets, it'll +# be throttled, by default for 5 minutes. You +# can configure the throttle period, and for +# constrained nodes, it may be a good idea to +# set a much higher throttle time. Real LXMF +# propagation nodes will never deliver messages +# with lower stamp values than required by the +# receiving node. + +# propagation_stamp_throttle = 5 + # The peering_cost option configures the target # value required for a remote node to peer with # and deliver messages to this node.