Skip to content

Commit f719d44

Browse files
committed
Transport optimisations
1 parent af890d9 commit f719d44

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

RNS/Transport.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ def outbound(packet):
377377
# just the relevant interface if the packet has an attached
378378
# interface, or belongs to a link.
379379
else:
380+
stored_hash = False
380381
for interface in Transport.interfaces:
381382
if interface.OUT:
382383
should_transmit = True
@@ -391,8 +392,10 @@ def outbound(packet):
391392
if should_transmit:
392393
RNS.log("Transmitting "+str(len(packet.raw))+" bytes on: "+str(interface), RNS.LOG_EXTREME)
393394
RNS.log("Hash is "+RNS.prettyhexrep(packet.packet_hash), RNS.LOG_EXTREME)
394-
if not packet.packet_hash in Transport.packet_hashlist:
395+
396+
if not stored_hash:
395397
Transport.packet_hashlist.append(packet.packet_hash)
398+
396399
interface.processOutgoing(packet.raw)
397400
sent = True
398401

@@ -1140,13 +1143,17 @@ def interface_to_shared_instance(interface):
11401143

11411144
@staticmethod
11421145
def exit_handler():
1143-
RNS.log("Saving packet hashlist to storage...", RNS.LOG_VERBOSE)
11441146
try:
1147+
if not RNS.Reticulum.transport_enabled():
1148+
Transport.packet_hashlist = []
1149+
else:
1150+
RNS.log("Saving packet hashlist to storage...", RNS.LOG_VERBOSE)
1151+
11451152
packet_hashlist_path = RNS.Reticulum.storagepath+"/packet_hashlist"
11461153
file = open(packet_hashlist_path, "wb")
11471154
file.write(umsgpack.packb(Transport.packet_hashlist))
11481155
file.close()
1149-
RNS.log("Done packet hashlist to storage", RNS.LOG_VERBOSE)
1156+
11501157
except Exception as e:
11511158
RNS.log("Could not save packet hashlist to storage, the contained exception was: "+str(e), RNS.LOG_ERROR)
11521159

0 commit comments

Comments
 (0)