mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-22 21:50:18 +00:00
Cleanup
This commit is contained in:
parent
31104c6e9c
commit
c9de260e00
@ -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()
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user