mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-12-26 07:59:36 -05:00
Work on Resource optimisation
This commit is contained in:
parent
0a8b755230
commit
be6910e4e0
@ -44,8 +44,17 @@ class Resource:
|
|||||||
"""
|
"""
|
||||||
WINDOW_FLEXIBILITY = 4
|
WINDOW_FLEXIBILITY = 4
|
||||||
WINDOW_MIN = 1
|
WINDOW_MIN = 1
|
||||||
WINDOW_MAX = 10
|
WINDOW_MAX_SLOW = 10
|
||||||
WINDOW = 4
|
WINDOW_MAX_FAST = 76
|
||||||
|
|
||||||
|
WINDOW_MAX = 76
|
||||||
|
WINDOW = WINDOW_MAX
|
||||||
|
# TODO: Reset
|
||||||
|
# WINDOW = 4
|
||||||
|
|
||||||
|
RATE_SLOW = 1000
|
||||||
|
RATE_FAST = 10*1000*1000
|
||||||
|
|
||||||
MAPHASH_LEN = 4
|
MAPHASH_LEN = 4
|
||||||
SDU = RNS.Packet.MDU
|
SDU = RNS.Packet.MDU
|
||||||
RANDOM_HASH_SIZE = 4
|
RANDOM_HASH_SIZE = 4
|
||||||
@ -710,26 +719,33 @@ class Resource:
|
|||||||
|
|
||||||
requested_hashes = request_data[pad+RNS.Identity.HASHLENGTH//8:]
|
requested_hashes = request_data[pad+RNS.Identity.HASHLENGTH//8:]
|
||||||
|
|
||||||
for i in range(0,len(requested_hashes)//Resource.MAPHASH_LEN):
|
# Define the search scope
|
||||||
requested_hash = requested_hashes[i*Resource.MAPHASH_LEN:(i+1)*Resource.MAPHASH_LEN]
|
search_start = self.receiver_min_consecutive_height
|
||||||
|
search_end = self.receiver_min_consecutive_height+ResourceAdvertisement.COLLISION_GUARD_SIZE
|
||||||
|
|
||||||
search_start = self.receiver_min_consecutive_height
|
map_hashes = []
|
||||||
search_end = self.receiver_min_consecutive_height+ResourceAdvertisement.COLLISION_GUARD_SIZE
|
for i in range(0,len(requested_hashes)//Resource.MAPHASH_LEN):
|
||||||
for part in self.parts[search_start:search_end]:
|
map_hash = requested_hashes[i*Resource.MAPHASH_LEN:(i+1)*Resource.MAPHASH_LEN]
|
||||||
if part.map_hash == requested_hash:
|
map_hashes.append(map_hash)
|
||||||
try:
|
|
||||||
if not part.sent:
|
search_scope = self.parts[search_start:search_end]
|
||||||
part.send()
|
requested_parts = list(filter(lambda part: part.map_hash in map_hashes, search_scope))
|
||||||
self.sent_parts += 1
|
|
||||||
else:
|
for part in requested_parts:
|
||||||
part.resend()
|
try:
|
||||||
self.last_activity = time.time()
|
if not part.sent:
|
||||||
self.last_part_sent = self.last_activity
|
part.send()
|
||||||
break
|
self.sent_parts += 1
|
||||||
except Exception as e:
|
else:
|
||||||
RNS.log("Resource could not send parts, cancelling transfer!", RNS.LOG_DEBUG)
|
part.resend()
|
||||||
RNS.log("The contained exception was: "+str(e), RNS.LOG_DEBUG)
|
|
||||||
self.cancel()
|
self.last_activity = time.time()
|
||||||
|
self.last_part_sent = self.last_activity
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
RNS.log("Resource could not send parts, cancelling transfer!", RNS.LOG_DEBUG)
|
||||||
|
RNS.log("The contained exception was: "+str(e), RNS.LOG_DEBUG)
|
||||||
|
self.cancel()
|
||||||
|
|
||||||
if wants_more_hashmap:
|
if wants_more_hashmap:
|
||||||
last_map_hash = request_data[1:Resource.MAPHASH_LEN+1]
|
last_map_hash = request_data[1:Resource.MAPHASH_LEN+1]
|
||||||
|
Loading…
Reference in New Issue
Block a user