mirror of
https://github.com/markqvist/NomadNet.git
synced 2026-11-19 14:36:28 -05:00
Added ability to configure node stamp value and link cost
This commit is contained in:
parent
9dd3d861ea
commit
c47f9e4d97
2 changed files with 15 additions and 0 deletions
|
|
@ -21,6 +21,8 @@ class Node:
|
|||
self.app = app
|
||||
self.identity = self.app.identity
|
||||
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, "nomadnetwork", "node")
|
||||
self.destination.set_link_cost(self.app.node_link_cost)
|
||||
if self.app.node_stamp_value: self.destination.set_value(self.app.node_stamp_value)
|
||||
self.last_announce = time.time()
|
||||
self.last_file_refresh = time.time()
|
||||
self.last_page_refresh = time.time()
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class NomadNetworkApp:
|
|||
START_ANNOUNCE_DELAY = 3
|
||||
|
||||
REQUIRED_DESTINATION_TYPES = ["nomadnetwork.node", "rrc.hub"]
|
||||
DEFAULT_LINK_COST = 17.8
|
||||
|
||||
def exit_handler(self):
|
||||
self.should_run_jobs = False
|
||||
|
|
@ -153,6 +154,8 @@ class NomadNetworkApp:
|
|||
self.lxmf_max_sync_size = None
|
||||
self.lxmf_max_incoming_size = None
|
||||
self.node_propagation_cost = LXMF.LXMRouter.PROPAGATION_COST
|
||||
self.node_link_cost = self.DEFAULT_LINK_COST
|
||||
self.node_stamp_value = None
|
||||
|
||||
self.periodic_lxmf_sync = True
|
||||
self.lxmf_sync_interval = 360*60
|
||||
|
|
@ -1145,6 +1148,16 @@ class NomadNetworkApp:
|
|||
else:
|
||||
self.node_name = self.config["node"]["node_name"]
|
||||
|
||||
if "link_cost" in self.config["node"]:
|
||||
value = self.config["node"].as_float("link_cost")
|
||||
if value < 1: value = 1
|
||||
self.node_link_cost = RNS.Stamps.quantize_cost(value)
|
||||
|
||||
if "stamp_value" in self.config["node"]:
|
||||
value = self.config["node"].as_float("stamp_value")
|
||||
if value < 1: value = 1
|
||||
self.node_stamp_value = RNS.Stamps.quantize_cost(value)
|
||||
|
||||
if not "disable_propagation" in self.config["node"]:
|
||||
self.disable_propagation = True
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue