This commit is contained in:
Mark Qvist 2022-04-18 16:25:11 +02:00
parent 31104c6e9c
commit c9de260e00
2 changed files with 2 additions and 34 deletions

View File

@ -43,26 +43,11 @@ class Interface:
def get_hash(self):
return RNS.Identity.full_hash(str(self).encode("utf-8"))
# TODO: Clean
# def bogus_queue(self):
# self.announce_queue = []
# import random
# import time
# now = time.time()
# random.seed(45)
# for i in range(1,32):
# entry = {"time": now+i*3, "hops":random.randint(4,16), "raw": str("bogus_data_"+str(i)).encode("utf-8")}
# self.announce_queue.append(entry)
def process_announce_queue(self):
if not hasattr(self, "announce_cap"):
self.announce_cap = RNS.Reticulum.ANNOUNCE_CAP
if hasattr(self, "announce_queue"):
# TODO: Clean
# RNS.log("Processing announce queue on "+str(self), RNS.LOG_DEBUG)
try:
now = time.time()
stale = []
@ -86,11 +71,7 @@ class Interface:
self.processOutgoing(selected["raw"])
self.announce_queue.remove(selected)
# TODO: Clean debug statements
# RNS.log("Sent queued announce with "+str(selected["hops"])+" hops on "+str(self))
if len(self.announce_queue) > 0:
# TODO: Clean debug statements
# RNS.log("Still have "+str(len(self.announce_queue))+" announces in queue, scheduling next for tx in "+str(round(wait_time*1000,6))+"ms", RNS.LOG_DEBUG)
timer = threading.Timer(wait_time, self.process_announce_queue)
timer.start()

View File

@ -82,7 +82,7 @@ class Transport:
# TODO: "destination_table" should really be renamed to "path_table"
# Notes on memory usage: 1 megabyte of memory can store approximately
# 55.100 path table entries or approximately 22.300 link table entries.
announce_table = {} # A table for storing announces currently waiting to be retransmitted
destination_table = {} # A lookup table containing the next hop to a given destination
reverse_table = {} # A lookup table for storing packet hashes used to return proofs and replies
@ -558,7 +558,6 @@ class Transport:
should_transmit = False
else:
# TODO: Remove logging statements
if packet.hops > 0:
if not hasattr(interface, "announce_cap"):
@ -583,30 +582,18 @@ class Transport:
entry = {"time": outbound_time, "hops": packet.hops, "raw": packet.raw}
queued_announces = True if len(interface.announce_queue) > 0 else False
interface.announce_queue.append(entry)
# TODO: Clean
# RNS.log("Added announce to queue on "+str(interface), RNS.LOG_DEBUG)
if not queued_announces:
# TODO: Clean
# RNS.log("Interface "+str(interface)+" still waiting for announce allowance", RNS.LOG_DEBUG)
wait_time = max(interface.announce_allowed_at - time.time(), 0)
timer = threading.Timer(wait_time, interface.process_announce_queue)
timer.start()
# TODO: Clean
# RNS.log("Triggering run in "+str(wait_time)+" seconds", RNS.LOG_DEBUG)
else:
# TODO: Clean
# RNS.log("Interface "+str(interface)+" has announces in queue, adding directly to it", RNS.LOG_DEBUG)
pass
else:
# TODO: Clean
# RNS.log("Not retransmitting announce on "+str(interface)+" since the queue is full", RNS.LOG_DEBUG)
pass
else:
# TODO: Clean
# RNS.log("Skipping announce cap calculations for "+str(packet.hops)+" hop packet", RNS.LOG_DEBUG)
pass
if should_transmit: