Cleanup
This commit is contained in:
parent
31104c6e9c
commit
c9de260e00
@ -43,26 +43,11 @@ class Interface:
|
|||||||
def get_hash(self):
|
def get_hash(self):
|
||||||
return RNS.Identity.full_hash(str(self).encode("utf-8"))
|
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):
|
def process_announce_queue(self):
|
||||||
if not hasattr(self, "announce_cap"):
|
if not hasattr(self, "announce_cap"):
|
||||||
self.announce_cap = RNS.Reticulum.ANNOUNCE_CAP
|
self.announce_cap = RNS.Reticulum.ANNOUNCE_CAP
|
||||||
|
|
||||||
if hasattr(self, "announce_queue"):
|
if hasattr(self, "announce_queue"):
|
||||||
# TODO: Clean
|
|
||||||
# RNS.log("Processing announce queue on "+str(self), RNS.LOG_DEBUG)
|
|
||||||
try:
|
try:
|
||||||
now = time.time()
|
now = time.time()
|
||||||
stale = []
|
stale = []
|
||||||
@ -86,11 +71,7 @@ class Interface:
|
|||||||
|
|
||||||
self.processOutgoing(selected["raw"])
|
self.processOutgoing(selected["raw"])
|
||||||
self.announce_queue.remove(selected)
|
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:
|
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 = threading.Timer(wait_time, self.process_announce_queue)
|
||||||
timer.start()
|
timer.start()
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class Transport:
|
|||||||
# TODO: "destination_table" should really be renamed to "path_table"
|
# TODO: "destination_table" should really be renamed to "path_table"
|
||||||
# Notes on memory usage: 1 megabyte of memory can store approximately
|
# Notes on memory usage: 1 megabyte of memory can store approximately
|
||||||
# 55.100 path table entries or approximately 22.300 link table entries.
|
# 55.100 path table entries or approximately 22.300 link table entries.
|
||||||
|
|
||||||
announce_table = {} # A table for storing announces currently waiting to be retransmitted
|
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
|
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
|
reverse_table = {} # A lookup table for storing packet hashes used to return proofs and replies
|
||||||
@ -558,7 +558,6 @@ class Transport:
|
|||||||
should_transmit = False
|
should_transmit = False
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# TODO: Remove logging statements
|
|
||||||
if packet.hops > 0:
|
if packet.hops > 0:
|
||||||
|
|
||||||
if not hasattr(interface, "announce_cap"):
|
if not hasattr(interface, "announce_cap"):
|
||||||
@ -583,30 +582,18 @@ class Transport:
|
|||||||
entry = {"time": outbound_time, "hops": packet.hops, "raw": packet.raw}
|
entry = {"time": outbound_time, "hops": packet.hops, "raw": packet.raw}
|
||||||
queued_announces = True if len(interface.announce_queue) > 0 else False
|
queued_announces = True if len(interface.announce_queue) > 0 else False
|
||||||
interface.announce_queue.append(entry)
|
interface.announce_queue.append(entry)
|
||||||
# TODO: Clean
|
|
||||||
# RNS.log("Added announce to queue on "+str(interface), RNS.LOG_DEBUG)
|
|
||||||
|
|
||||||
if not queued_announces:
|
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)
|
wait_time = max(interface.announce_allowed_at - time.time(), 0)
|
||||||
timer = threading.Timer(wait_time, interface.process_announce_queue)
|
timer = threading.Timer(wait_time, interface.process_announce_queue)
|
||||||
timer.start()
|
timer.start()
|
||||||
# TODO: Clean
|
|
||||||
# RNS.log("Triggering run in "+str(wait_time)+" seconds", RNS.LOG_DEBUG)
|
|
||||||
else:
|
else:
|
||||||
# TODO: Clean
|
|
||||||
# RNS.log("Interface "+str(interface)+" has announces in queue, adding directly to it", RNS.LOG_DEBUG)
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# TODO: Clean
|
|
||||||
# RNS.log("Not retransmitting announce on "+str(interface)+" since the queue is full", RNS.LOG_DEBUG)
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# TODO: Clean
|
|
||||||
# RNS.log("Skipping announce cap calculations for "+str(packet.hops)+" hop packet", RNS.LOG_DEBUG)
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if should_transmit:
|
if should_transmit:
|
||||||
|
Loading…
Reference in New Issue
Block a user