Fixed resource transfers timing out over fast links
This commit is contained in:
parent
7867d7ded9
commit
a24a9623d3
@ -23,6 +23,8 @@ class Identity:
|
|||||||
HASHLENGTH = 256 # In bits
|
HASHLENGTH = 256 # In bits
|
||||||
SIGLENGTH = KEYSIZE
|
SIGLENGTH = KEYSIZE
|
||||||
|
|
||||||
|
TRUNCATED_HASHLENGTH = 80 # In bits
|
||||||
|
|
||||||
# Storage
|
# Storage
|
||||||
known_destinations = {}
|
known_destinations = {}
|
||||||
|
|
||||||
@ -78,7 +80,7 @@ class Identity:
|
|||||||
digest = hashes.Hash(hashes.SHA256(), backend=default_backend())
|
digest = hashes.Hash(hashes.SHA256(), backend=default_backend())
|
||||||
digest.update(data)
|
digest.update(data)
|
||||||
|
|
||||||
return digest.finalize()[:10]
|
return digest.finalize()[:(Identity.TRUNCATED_HASHLENGTH/8)]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getRandomHash():
|
def getRandomHash():
|
||||||
|
@ -18,6 +18,7 @@ class Resource:
|
|||||||
# intelligently
|
# intelligently
|
||||||
MAX_RETRIES = 5
|
MAX_RETRIES = 5
|
||||||
SENDER_GRACE_TIME = 10
|
SENDER_GRACE_TIME = 10
|
||||||
|
RETRY_GRACE_TIME = 0.25
|
||||||
|
|
||||||
HASHMAP_IS_NOT_EXHAUSTED = 0x00
|
HASHMAP_IS_NOT_EXHAUSTED = 0x00
|
||||||
HASHMAP_IS_EXHAUSTED = 0xFF
|
HASHMAP_IS_EXHAUSTED = 0xFF
|
||||||
@ -232,7 +233,7 @@ class Resource:
|
|||||||
elif self.status == Resource.TRANSFERRING:
|
elif self.status == Resource.TRANSFERRING:
|
||||||
if not self.initiator:
|
if not self.initiator:
|
||||||
rtt = self.link.rtt if self.rtt == None else self.rtt
|
rtt = self.link.rtt if self.rtt == None else self.rtt
|
||||||
sleep_time = self.last_activity + (rtt*self.timeout_factor) - time.time()
|
sleep_time = self.last_activity + (rtt*self.timeout_factor) + Resource.RETRY_GRACE_TIME - time.time()
|
||||||
|
|
||||||
if sleep_time < 0:
|
if sleep_time < 0:
|
||||||
if self.retries_left > 0:
|
if self.retries_left > 0:
|
||||||
|
@ -236,6 +236,7 @@ class Transport:
|
|||||||
if packet.packet_type == RNS.Packet.ANNOUNCE:
|
if packet.packet_type == RNS.Packet.ANNOUNCE:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
RNS.log("Filtered packet with hash "+RNS.prettyhexrep(packet.packet_hash), RNS.LOG_DEBUG)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -261,7 +262,6 @@ class Transport:
|
|||||||
RNS.log("Received packet in transport for "+RNS.prettyhexrep(packet.destination_hash)+" with matching transport ID, transporting it...", RNS.LOG_DEBUG)
|
RNS.log("Received packet in transport for "+RNS.prettyhexrep(packet.destination_hash)+" with matching transport ID, transporting it...", RNS.LOG_DEBUG)
|
||||||
if packet.destination_hash in Transport.destination_table:
|
if packet.destination_hash in Transport.destination_table:
|
||||||
next_hop = Transport.destination_table[packet.destination_hash][1]
|
next_hop = Transport.destination_table[packet.destination_hash][1]
|
||||||
RNS.log("Packet hops: "+str(packet.hops), RNS.LOG_DEBUG)
|
|
||||||
RNS.log("Next hop to destination is "+RNS.prettyhexrep(next_hop)+", transporting it.", RNS.LOG_DEBUG)
|
RNS.log("Next hop to destination is "+RNS.prettyhexrep(next_hop)+", transporting it.", RNS.LOG_DEBUG)
|
||||||
new_raw = packet.raw[0:1]
|
new_raw = packet.raw[0:1]
|
||||||
new_raw += struct.pack("!B", packet.hops)
|
new_raw += struct.pack("!B", packet.hops)
|
||||||
|
Loading…
Reference in New Issue
Block a user