Improved path response logic

This commit is contained in:
Mark Qvist 2024-05-04 21:57:03 +02:00
parent f595648a9b
commit d2feb8b136

View File

@ -65,7 +65,7 @@ class Transport:
PATH_REQUEST_TIMEOUT = 15 # Default timuout for client path requests in seconds PATH_REQUEST_TIMEOUT = 15 # Default timuout for client path requests in seconds
PATH_REQUEST_GRACE = 0.4 # Grace time before a path announcement is made, allows directly reachable peers to respond first PATH_REQUEST_GRACE = 0.4 # Grace time before a path announcement is made, allows directly reachable peers to respond first
PATH_REQUEST_RG = 1.0 # Extra grace time for roaming-mode interfaces to allow more suitable peers to respond first PATH_REQUEST_RG = 0.6 # Extra grace time for roaming-mode interfaces to allow more suitable peers to respond first
PATH_REQUEST_MI = 20 # Minimum interval in seconds for automated path requests PATH_REQUEST_MI = 20 # Minimum interval in seconds for automated path requests
STATE_UNKNOWN = 0x00 STATE_UNKNOWN = 0x00
@ -2175,6 +2175,7 @@ class Transport:
else: else:
return False return False
@staticmethod
def path_is_unresponsive(destination_hash): def path_is_unresponsive(destination_hash):
if destination_hash in Transport.path_states: if destination_hash in Transport.path_states:
if Transport.path_states[destination_hash] == Transport.STATE_UNRESPONSIVE: if Transport.path_states[destination_hash] == Transport.STATE_UNRESPONSIVE:
@ -2339,8 +2340,12 @@ class Transport:
if is_from_local_client: if is_from_local_client:
retransmit_timeout = now retransmit_timeout = now
else: else:
# TODO: Consider this timing if Transport.is_local_client_interface(Transport.next_hop_interface(destination_hash)):
retransmit_timeout = now + Transport.PATH_REQUEST_GRACE # + (RNS.rand() * Transport.PATHFINDER_RW) RNS.log("Path request destination "+RNS.prettyhexrep(destination_hash)+" is on a local client interface, rebroadcasting immediately", RNS.LOG_EXTREME)
retransmit_timeout = now
else:
retransmit_timeout = now + Transport.PATH_REQUEST_GRACE
# If we are answering on a roaming-mode interface, wait a # If we are answering on a roaming-mode interface, wait a
# little longer, to allow potential more well-connected # little longer, to allow potential more well-connected