mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-10-25 18:40:17 -04:00
Avoid additional packet hashing under lock in inbound
This commit is contained in:
parent
629e4fde2d
commit
d81421dad3
2 changed files with 8 additions and 4 deletions
|
|
@ -350,6 +350,10 @@ class Packet:
|
|||
|
||||
def getTruncatedHash(self): return RNS.Identity.truncated_hash(self.get_hashable_part())
|
||||
|
||||
@property
|
||||
def truncated_packet_hash(self):
|
||||
return self.packet_hash[:RNS.Reticulum.TRUNCATED_HASHLENGTH//8]
|
||||
|
||||
def get_hashable_part(self):
|
||||
hashable_part = bytes([self.raw[0] & 0b00001111])
|
||||
if self.header_type == Packet.HEADER_2: hashable_part += self.raw[(RNS.Identity.TRUNCATED_HASHLENGTH//8)+2:]
|
||||
|
|
@ -380,7 +384,7 @@ class Packet:
|
|||
|
||||
class ProofDestination:
|
||||
def __init__(self, packet):
|
||||
self.hash = packet.get_hash()[:RNS.Reticulum.TRUNCATED_HASHLENGTH//8];
|
||||
self.hash = packet.truncated_packet_hash;
|
||||
self.type = RNS.Destination.SINGLE
|
||||
|
||||
def encrypt(self, plaintext): return plaintext
|
||||
|
|
@ -405,8 +409,8 @@ class PacketReceipt:
|
|||
|
||||
# Creates a new packet receipt from a sent packet
|
||||
def __init__(self, packet):
|
||||
self.hash = packet.get_hash()
|
||||
self.truncated_hash = packet.getTruncatedHash()
|
||||
self.hash = packet.packet_hash
|
||||
self.truncated_hash = packet.truncated_packet_hash
|
||||
self.sent = True
|
||||
self.sent_at = time.time()
|
||||
self.proved = False
|
||||
|
|
|
|||
|
|
@ -2103,7 +2103,7 @@ class Transport:
|
|||
outbound_interface, # 1: Outbound interface
|
||||
time.time() ] # 2: Timestamp
|
||||
|
||||
with Transport.reverse_table_lock: Transport.reverse_table[packet.getTruncatedHash()] = reverse_entry
|
||||
with Transport.reverse_table_lock: Transport.reverse_table[packet.truncated_packet_hash] = reverse_entry
|
||||
|
||||
if Transport.local_hops_delta != 0 and from_local_client and not to_local_client: new_raw = Transport.mangle_hops(new_raw, Transport.local_hops_delta)
|
||||
Transport.transmit(outbound_interface, new_raw)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue