Allow configuring propagation node stamp cost
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Has been cancelled

This commit is contained in:
Mark Qvist 2025-11-01 18:27:47 +01:00
parent 373315423e
commit ad2cefa329
2 changed files with 59 additions and 3 deletions

View file

@ -6,6 +6,8 @@ import nomadnet
import threading
import RNS.vendor.umsgpack as msgpack
from LXMF import pn_announce_data_is_valid
class PNAnnounceHandler:
def __init__(self, owner):
self.aspect_filter = "lxmf.propagation"
@ -13,10 +15,10 @@ class PNAnnounceHandler:
def received_announce(self, destination_hash, announced_identity, app_data):
try:
if type(app_data) == bytes:
if pn_announce_data_is_valid(app_data):
data = msgpack.unpackb(app_data)
if data[0] == True:
if data[2] == True:
RNS.log("Received active propagation node announce from "+RNS.prettyhexrep(destination_hash))
associated_peer = RNS.Destination.hash_from_name_and_identity("lxmf.delivery", announced_identity)

View file

@ -130,6 +130,7 @@ class NomadNetworkApp:
self.lxmf_max_propagation_size = None
self.lxmf_max_sync_size = None
self.lxmf_max_incoming_size = None
self.node_propagation_cost = LXMF.LXMRouter.PROPAGATION_COST
self.periodic_lxmf_sync = True
self.lxmf_sync_interval = 360*60
@ -304,7 +305,7 @@ class NomadNetworkApp:
self.message_router = LXMF.LXMRouter(
identity = self.identity, storagepath = self.storagepath, autopeer = True,
propagation_limit = self.lxmf_max_propagation_size, sync_limit = self.lxmf_max_sync_size, delivery_limit = self.lxmf_max_incoming_size,
max_peers = self.max_peers, static_peers = static_peers,
max_peers = self.max_peers, static_peers = static_peers, propagation_cost=self.node_propagation_cost
)
self.message_router.register_delivery_callback(self.lxmf_delivery)
@ -911,6 +912,13 @@ class NomadNetworkApp:
value = 1
self.node_announce_interval = value
if not "propagation_cost" in self.config["node"]:
self.node_propagation_cost = 16
else:
value = self.config["node"].as_int("propagation_cost")
if value < 13: value = 13
self.node_propagation_cost = value
if "pages_path" in self.config["node"]:
self.pagespath = self.config["node"]["pages_path"]
@ -1186,8 +1194,40 @@ announce_at_start = Yes
# you should disable running a propagation node.
# Due to lots of propagation nodes being
# available, this is currently the default.
disable_propagation = Yes
# For clients and other propagation nodes
# delivering messages via this node, you can
# configure the minimum required propagation
# stamp costs. All messages delivered to the
# propagation node network must have a valid
# propagation stamp, or they will be rejected.
# Clients automatically detect the stamp cost
# for the node they are delivering to, and
# compute a corresponding stamp before trying
# to deliver the message to the propagation
# node.
#
# Propagation stamps are easier to verify in
# large batches, and therefore also somewhat
# easier to compute for the senders. As such,
# a reasonable propagation stamp cost should
# be a bit higher than the normal peer-to-peer
# stamp costs.
#
# Propagation stamps does not incur any extra
# load for propagation nodes processing them,
# since they are only required to verify that
# they are correct, and only the generation
# is computationally costly. Setting a sensible
# propagation stamp cost (and periodically
# checking the average network consensus) helps
# keep spam and misuse out of the propagation
# node network.
propagation_cost = 16
# The maximum amount of storage to use for
# the LXMF Propagation Node message store,
# specified in megabytes. When this limit
@ -1197,12 +1237,14 @@ disable_propagation = Yes
# new and small. Large and old messages will
# be removed first. This setting is optional
# and defaults to 2 gigabytes.
# message_storage_limit = 2000
# The maximum accepted transfer size per in-
# coming propagation message, in kilobytes.
# This sets the upper limit for the size of
# single messages accepted onto this node.
max_transfer_size = 256
# The maximum accepted transfer size per in-
@ -1213,6 +1255,7 @@ max_transfer_size = 256
# within this limit, it will prioritise sending
# the smallest messages first, and try again
# with any remaining messages at a later point.
max_sync_size = 10240
# You can tell the LXMF message router to
@ -1222,29 +1265,34 @@ max_sync_size = 10240
# keeping messages for destinations specified
# with this option. This setting is optional,
# and generally you do not need to use it.
# prioritise_destinations = 41d20c727598a3fbbdf9106133a3a0ed, d924b81822ca24e68e2effea99bcb8cf
# You can configure the maximum number of other
# propagation nodes that this node will peer
# with automatically. The default is 20.
# max_peers = 20
# You can configure a list of static propagation
# node peers, that this node will always be
# peered with, by specifying a list of
# destination hashes.
# static_peers = e17f833c4ddf8890dd3a79a6fea8161d, 5a2d0029b6e5ec87020abaea0d746da4
# You can specify the interval in minutes for
# rescanning the hosted pages path. By default,
# this option is disabled, and the pages path
# will only be scanned on startup.
# page_refresh_interval = 0
# You can specify the interval in minutes for
# rescanning the hosted files path. By default,
# this option is disabled, and the files path
# will only be scanned on startup.
# file_refresh_interval = 0
[printing]
@ -1253,6 +1301,7 @@ max_sync_size = 10240
# various kinds of information and messages.
# Printing messages is disabled by default
print_messages = No
# You can configure a custom template for
@ -1260,24 +1309,29 @@ print_messages = No
# option, set a path to the template and
# restart Nomad Network, a default template
# will be created that you can edit.
# message_template = ~/.nomadnetwork/print_template_msg.txt
# You can configure Nomad Network to only
# print messages from trusted destinations.
# print_from = trusted
# Or specify the source LXMF addresses that
# will automatically have messages printed
# on arrival.
# print_from = 76fe5751a56067d1e84eef3e88eab85b, 0e70b5848eb57c13154154feaeeb89b7
# Or allow printing from anywhere, if you
# are feeling brave and adventurous.
# print_from = everywhere
# You can configure the printing command.
# This will use the default CUPS printer on
# your system.
print_command = lp
# You can specify what printer to use