Skip to content

Commit d2feb8b

Browse files
committed
Improved path response logic
1 parent f595648 commit d2feb8b

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

RNS/Transport.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Transport:
6565

6666
PATH_REQUEST_TIMEOUT = 15 # Default timuout for client path requests in seconds
6767
PATH_REQUEST_GRACE = 0.4 # Grace time before a path announcement is made, allows directly reachable peers to respond first
68-
PATH_REQUEST_RG = 1.0 # Extra grace time for roaming-mode interfaces to allow more suitable peers to respond first
68+
PATH_REQUEST_RG = 0.6 # Extra grace time for roaming-mode interfaces to allow more suitable peers to respond first
6969
PATH_REQUEST_MI = 20 # Minimum interval in seconds for automated path requests
7070

7171
STATE_UNKNOWN = 0x00
@@ -2175,6 +2175,7 @@ def mark_path_unknown_state(destination_hash):
21752175
else:
21762176
return False
21772177

2178+
@staticmethod
21782179
def path_is_unresponsive(destination_hash):
21792180
if destination_hash in Transport.path_states:
21802181
if Transport.path_states[destination_hash] == Transport.STATE_UNRESPONSIVE:
@@ -2339,14 +2340,18 @@ def path_request(destination_hash, is_from_local_client, attached_interface, req
23392340
if is_from_local_client:
23402341
retransmit_timeout = now
23412342
else:
2342-
# TODO: Consider this timing
2343-
retransmit_timeout = now + Transport.PATH_REQUEST_GRACE # + (RNS.rand() * Transport.PATHFINDER_RW)
2344-
2345-
# If we are answering on a roaming-mode interface, wait a
2346-
# little longer, to allow potential more well-connected
2347-
# peers to answer first.
2348-
if attached_interface.mode == RNS.Interfaces.Interface.Interface.MODE_ROAMING:
2349-
retransmit_timeout += Transport.PATH_REQUEST_RG
2343+
if Transport.is_local_client_interface(Transport.next_hop_interface(destination_hash)):
2344+
RNS.log("Path request destination "+RNS.prettyhexrep(destination_hash)+" is on a local client interface, rebroadcasting immediately", RNS.LOG_EXTREME)
2345+
retransmit_timeout = now
2346+
2347+
else:
2348+
retransmit_timeout = now + Transport.PATH_REQUEST_GRACE
2349+
2350+
# If we are answering on a roaming-mode interface, wait a
2351+
# little longer, to allow potential more well-connected
2352+
# peers to answer first.
2353+
if attached_interface.mode == RNS.Interfaces.Interface.Interface.MODE_ROAMING:
2354+
retransmit_timeout += Transport.PATH_REQUEST_RG
23502355

23512356
# This handles an edge case where a peer sends a past
23522357
# request for a destination just after an announce for

0 commit comments

Comments
 (0)