Allow configuring max remote peering cost

This commit is contained in:
Mark Qvist 2025-11-01 18:27:11 +01:00
parent 4350a239e4
commit 401328fa16
3 changed files with 7 additions and 6 deletions

View file

@ -173,7 +173,7 @@ def pn_announce_data_is_valid(data):
try: try:
if type(data) != bytes: return False if type(data) != bytes: return False
else: data = msgpack.unpackb(data) else: data = msgpack.unpackb(data)
if len(data) < 7: raise ValueError("Invalid announce data: Insufficient peer data") if len(data) < 7: raise ValueError("Invalid announce data: Insufficient peer data, likely from deprecated LXMF version")
else: else:
try: int(data[1]) try: int(data[1])
except: raise ValueError("Invalid announce data: Could not decode timebase") except: raise ValueError("Invalid announce data: Could not decode timebase")

View file

@ -88,7 +88,7 @@ class LXMRouter:
enforce_ratchets=False, enforce_stamps=False, static_peers = [], max_peers=None, enforce_ratchets=False, enforce_stamps=False, static_peers = [], max_peers=None,
from_static_only=False, sync_strategy=LXMPeer.STRATEGY_PERSISTENT, from_static_only=False, sync_strategy=LXMPeer.STRATEGY_PERSISTENT,
propagation_cost=PROPAGATION_COST, propagation_cost_flexibility=PROPAGATION_COST_FLEX, propagation_cost=PROPAGATION_COST, propagation_cost_flexibility=PROPAGATION_COST_FLEX,
peering_cost=PEERING_COST, name=None): peering_cost=PEERING_COST, max_peering_cost=MAX_PEERING_COST, name=None):
random.seed(os.urandom(10)) random.seed(os.urandom(10))
@ -134,7 +134,7 @@ class LXMRouter:
self.propagation_stamp_cost = propagation_cost self.propagation_stamp_cost = propagation_cost
self.propagation_stamp_cost_flexibility = propagation_cost_flexibility self.propagation_stamp_cost_flexibility = propagation_cost_flexibility
self.peering_cost = peering_cost self.peering_cost = peering_cost
self.max_peering_cost = LXMRouter.MAX_PEERING_COST self.max_peering_cost = max_peering_cost
self.enforce_ratchets = enforce_ratchets self.enforce_ratchets = enforce_ratchets
self._enforce_stamps = enforce_stamps self._enforce_stamps = enforce_stamps
self.pending_deferred_stamps = {} self.pending_deferred_stamps = {}
@ -2420,7 +2420,6 @@ class LXMRouter:
else: else:
propagation_stamp = selected_lxm.get_propagation_stamp(target_cost=pn_target_cost) propagation_stamp = selected_lxm.get_propagation_stamp(target_cost=pn_target_cost)
RNS.log(f"Generated propagation stamp: {RNS.hexrep(propagation_stamp)}")
if propagation_stamp: if propagation_stamp:
selected_lxm.propagation_stamp = propagation_stamp selected_lxm.propagation_stamp = propagation_stamp
selected_lxm.defer_propagation_stamp = False selected_lxm.defer_propagation_stamp = False

View file

@ -377,6 +377,8 @@ def program_setup(configdir = None, rnsconfigdir = None, run_pn = False, on_inbo
propagation_limit = active_configuration["propagation_transfer_max_accepted_size"], propagation_limit = active_configuration["propagation_transfer_max_accepted_size"],
propagation_cost = active_configuration["propagation_stamp_cost_target"], propagation_cost = active_configuration["propagation_stamp_cost_target"],
propagation_cost_flexibility = active_configuration["propagation_stamp_cost_flexibility"], propagation_cost_flexibility = active_configuration["propagation_stamp_cost_flexibility"],
peering_cost = active_configuration["peering_cost"],
max_peering_cost = active_configuration["remote_peering_cost_max"],
sync_limit = active_configuration["propagation_sync_max_accepted_size"], sync_limit = active_configuration["propagation_sync_max_accepted_size"],
delivery_limit = active_configuration["delivery_transfer_max_accepted_size"], delivery_limit = active_configuration["delivery_transfer_max_accepted_size"],
max_peers = active_configuration["max_peers"], max_peers = active_configuration["max_peers"],
@ -1009,7 +1011,7 @@ autopeer_maxdepth = 4
# value required for a remote node to peer with # value required for a remote node to peer with
# and deliver messages to this node. # and deliver messages to this node.
# peering_cost = 10 # peering_cost = 18
# You can configure the maximum peering cost # You can configure the maximum peering cost
# of remote nodes that this node will peer with. # of remote nodes that this node will peer with.
@ -1019,7 +1021,7 @@ autopeer_maxdepth = 4
# more computation time during initial peering # more computation time during initial peering
# when generating the peering key. # when generating the peering key.
# remote_peering_cost_max = 12 # remote_peering_cost_max = 24
# You can tell the LXMF message router to # You can tell the LXMF message router to
# prioritise storage for one or more # prioritise storage for one or more