Let shared instance handle packet hashlist

This commit is contained in:
Mark Qvist 2025-05-10 20:58:54 +02:00
parent 48be5f65d8
commit 4d7f5b8ca6

View file

@ -1070,7 +1070,7 @@ class Transport:
if should_transmit:
if not stored_hash:
Transport.packet_hashlist.add(packet.packet_hash)
Transport.add_packet_hash(packet.packet_hash)
stored_hash = True
Transport.transmit(interface, packet.raw)
@ -1082,12 +1082,19 @@ class Transport:
Transport.jobs_locked = False
return sent
@staticmethod
def add_packet_hash(packet_hash):
if not Transport.owner.is_connected_to_shared_instance:
Transport.packet_hashlist.add(packet_hash)
@staticmethod
def packet_filter(packet):
# TODO: Think long and hard about this.
# Is it even strictly necessary with the current
# transport rules?
if Transport.owner.is_connected_to_shared_instance: return True
# Filter packets intended for other transport instances
if packet.transport_id != None and packet.packet_type != RNS.Packet.ANNOUNCE:
if packet.transport_id != Transport.identity.hash:
@ -1274,7 +1281,7 @@ class Transport:
remember_packet_hash = False
if remember_packet_hash:
Transport.packet_hashlist.add(packet.packet_hash)
Transport.add_packet_hash(packet.packet_hash)
# TODO: Enable when caching has been redesigned
# Transport.cache(packet)
@ -1440,7 +1447,7 @@ class Transport:
# Add this packet to the filter hashlist if we
# have determined that it's actually our turn
# to process it.
Transport.packet_hashlist.add(packet.packet_hash)
Transport.add_packet_hash(packet.packet_hash)
new_raw = packet.raw[0:1]
new_raw += struct.pack("!B", packet.hops)
@ -1954,7 +1961,7 @@ class Transport:
# Add this packet to the filter hashlist if we
# have determined that it's actually destined
# for this system, and then validate the proof
Transport.packet_hashlist.add(packet.packet_hash)
Transport.add_packet_hash(packet.packet_hash)
link.validate_proof(packet)
elif packet.context == RNS.Packet.RESOURCE_PRF: