mirror of
https://github.com/markqvist/LXMF.git
synced 2025-04-14 04:23:11 -04:00
Added wanted inbound peers to PN announce data
This commit is contained in:
parent
6d2eb4f973
commit
962d9c90d1
@ -45,6 +45,11 @@ class LXMFPropagationAnnounceHandler:
|
||||
if pn_announce_data_is_valid(data):
|
||||
node_timebase = data[1]
|
||||
propagation_transfer_limit = None
|
||||
if len(data) >= 4:
|
||||
try:
|
||||
wanted_inbound_peers = int(data[3])
|
||||
except:
|
||||
wanted_inbound_peers = None
|
||||
if len(data) >= 3:
|
||||
try:
|
||||
propagation_transfer_limit = float(data[2])
|
||||
@ -52,12 +57,12 @@ class LXMFPropagationAnnounceHandler:
|
||||
propagation_transfer_limit = None
|
||||
|
||||
if destination_hash in self.lxmrouter.static_peers:
|
||||
self.lxmrouter.peer(destination_hash, node_timebase, propagation_transfer_limit)
|
||||
self.lxmrouter.peer(destination_hash, node_timebase, propagation_transfer_limit, wanted_inbound_peers)
|
||||
|
||||
else:
|
||||
if data[0] == True:
|
||||
if RNS.Transport.hops_to(destination_hash) <= self.lxmrouter.autopeer_maxdepth:
|
||||
self.lxmrouter.peer(destination_hash, node_timebase, propagation_transfer_limit)
|
||||
self.lxmrouter.peer(destination_hash, node_timebase, propagation_transfer_limit, wanted_inbound_peers)
|
||||
|
||||
elif data[0] == False:
|
||||
self.lxmrouter.unpeer(destination_hash, node_timebase)
|
||||
|
@ -283,6 +283,7 @@ class LXMRouter:
|
||||
node_state, # Boolean flag signalling propagation node state
|
||||
int(time.time()), # Current node timebase
|
||||
self.propagation_per_transfer_limit, # Per-transfer limit for message propagation in kilobytes
|
||||
self.get_wanted_inbound_peers(), # How many more inbound peers this node wants
|
||||
]
|
||||
|
||||
data = msgpack.packb(announce_data)
|
||||
@ -888,6 +889,10 @@ class LXMRouter:
|
||||
self.save_outbound_stamp_costs()
|
||||
threading.Thread(target=self.save_outbound_stamp_costs, daemon=True).start()
|
||||
|
||||
def get_wanted_inbound_peers(self):
|
||||
# TODO: Implement
|
||||
return None
|
||||
|
||||
def get_announce_app_data(self, destination_hash):
|
||||
if destination_hash in self.delivery_destinations:
|
||||
delivery_destination = self.delivery_destinations[destination_hash]
|
||||
@ -1766,7 +1771,7 @@ class LXMRouter:
|
||||
### Peer Sync & Propagation ###########################
|
||||
#######################################################
|
||||
|
||||
def peer(self, destination_hash, timestamp, propagation_transfer_limit):
|
||||
def peer(self, destination_hash, timestamp, propagation_transfer_limit, wanted_inbound_peers = None):
|
||||
if destination_hash in self.peers:
|
||||
peer = self.peers[destination_hash]
|
||||
if timestamp > peer.peering_timebase:
|
||||
@ -1969,7 +1974,8 @@ class LXMRouter:
|
||||
# sane default value, and wait for an announce to arrive
|
||||
# that will update the peering config to the actual limit.
|
||||
propagation_transfer_limit = LXMRouter.PROPAGATION_LIMIT//4
|
||||
self.peer(remote_hash, remote_timebase, propagation_transfer_limit)
|
||||
wanted_inbound_peers = None
|
||||
self.peer(remote_hash, remote_timebase, propagation_transfer_limit, wanted_inbound_peers)
|
||||
else:
|
||||
remote_str = f"peer {remote_str}"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user