Fixed announce queue not clearing all announces with exceeded retry limit at the same time

This commit is contained in:
Mark Qvist 2023-09-30 00:25:47 +02:00
parent c79cb3aa20
commit b5cb3a65dd

View File

@ -352,12 +352,12 @@ class Transport:
# Process announces needing retransmission # Process announces needing retransmission
if time.time() > Transport.announces_last_checked+Transport.announces_check_interval: if time.time() > Transport.announces_last_checked+Transport.announces_check_interval:
completed_announces = []
for destination_hash in Transport.announce_table: for destination_hash in Transport.announce_table:
announce_entry = Transport.announce_table[destination_hash] announce_entry = Transport.announce_table[destination_hash]
if announce_entry[2] > Transport.PATHFINDER_R: if announce_entry[2] > Transport.PATHFINDER_R:
RNS.log("Completed announce processing for "+RNS.prettyhexrep(destination_hash)+", retry limit reached", RNS.LOG_EXTREME) RNS.log("Completed announce processing for "+RNS.prettyhexrep(destination_hash)+", retry limit reached", RNS.LOG_EXTREME)
Transport.announce_table.pop(destination_hash) completed_announces.append(destination_hash)
break
else: else:
if time.time() > announce_entry[1]: if time.time() > announce_entry[1]:
announce_entry[1] = time.time() + Transport.PATHFINDER_G + Transport.PATHFINDER_RW announce_entry[1] = time.time() + Transport.PATHFINDER_G + Transport.PATHFINDER_RW
@ -404,6 +404,10 @@ class Transport:
Transport.announce_table[destination_hash] = held_entry Transport.announce_table[destination_hash] = held_entry
RNS.log("Reinserting held announce into table", RNS.LOG_DEBUG) RNS.log("Reinserting held announce into table", RNS.LOG_DEBUG)
for destination_hash in completed_announces:
if destination_hash in Transport.announce_table:
Transport.announce_table.pop(destination_hash)
Transport.announces_last_checked = time.time() Transport.announces_last_checked = time.time()