@@ -775,12 +775,8 @@ def inbound(raw, interface=None):
775
775
# First, check that the announce is not for a destination
776
776
# local to this system, and that hops are less than the max
777
777
if (not any (packet .destination_hash == d .hash for d in Transport .destinations ) and packet .hops < Transport .PATHFINDER_M + 1 ):
778
- random_blob = packet .data [RNS .Identity .KEYSIZE // 8 + 10 :RNS .Identity .KEYSIZE // 8 + 20 ]
779
-
778
+ random_blob = packet .data [RNS .Identity .KEYSIZE // 8 :RNS .Identity .KEYSIZE // 8 + RNS .Reticulum .TRUNCATED_HASHLENGTH // 8 ]
780
779
announce_emitted = int .from_bytes (random_blob [5 :10 ], "big" )
781
- # TODO: Remove
782
- RNS .log ("ArB: " + RNS .hexrep (random_blob ))
783
- RNS .log ("Announce timestamp is: " + str (announce_emitted ))
784
780
random_blobs = []
785
781
if packet .destination_hash in Transport .destination_table :
786
782
random_blobs = Transport .destination_table [packet .destination_hash ][4 ]
@@ -807,17 +803,12 @@ def inbound(raw, interface=None):
807
803
path_expires = Transport .destination_table [packet .destination_hash ][3 ]
808
804
809
805
path_announce_emitted = 0
810
- for random_blob in random_blobs :
811
- path_announce_emitted = max (path_announce_emitted , int .from_bytes (random_blob [5 :10 ], "big" ))
812
- if path_announce_emitted > announce_emitted :
806
+ for path_random_blob in random_blobs :
807
+ path_announce_emitted = max (path_announce_emitted , int .from_bytes (path_random_blob [5 :10 ], "big" ))
808
+ if path_announce_emitted >= announce_emitted :
813
809
break
814
810
815
- # TODO: Remove
816
- RNS .log ("PA e: " + str (path_announce_emitted ))
817
- RNS .log ("A e: " + str (announce_emitted ))
818
- ##############
819
-
820
- if (now >= path_expires or announce_emitted >= path_announce_emitted ):
811
+ if (now >= path_expires ):
821
812
# We also check that the announce hash is
822
813
# different from ones we've already heard,
823
814
# to avoid loops in the network
@@ -829,7 +820,13 @@ def inbound(raw, interface=None):
829
820
else :
830
821
should_add = False
831
822
else :
832
- should_add = False
823
+ if (announce_emitted > path_announce_emitted ):
824
+ if not random_blob in random_blobs :
825
+ RNS .log ("Replacing destination table entry for " + str (RNS .prettyhexrep (packet .destination_hash ))+ " with new announce, since it was more recently emitted" , RNS .LOG_DEBUG )
826
+ should_add = True
827
+ else :
828
+ should_add = False
829
+
833
830
else :
834
831
# If this destination is unknown in our table
835
832
# we should add it
0 commit comments