From 55c0f44e58ba38ace79d6733f13c7623c7824f29 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 16 May 2021 16:42:07 +0200 Subject: [PATCH] Refactored Packet method names --- RNS/Identity.py | 2 +- RNS/Link.py | 2 +- RNS/Packet.py | 20 ++++++++++---------- RNS/Resource.py | 2 +- RNS/Transport.py | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/RNS/Identity.py b/RNS/Identity.py index e5b3e7a..efe8154 100644 --- a/RNS/Identity.py +++ b/RNS/Identity.py @@ -329,7 +329,7 @@ class Identity: proof_data = packet.packet_hash + signature if destination == None: - destination = packet.generateProofDestination() + destination = packet.generate_proof_destination() proof = RNS.Packet(destination, proof_data, RNS.Packet.PROOF, attached_interface = packet.receiving_interface) proof.send() diff --git a/RNS/Link.py b/RNS/Link.py index 5c9ab65..1b9b4a4 100644 --- a/RNS/Link.py +++ b/RNS/Link.py @@ -448,7 +448,7 @@ class Link: resource_hash = packet.data[0:RNS.Identity.HASHLENGTH//8] for resource in self.outgoing_resources: if resource_hash == resource.hash: - resource.validateProof(packet.data) + resource.validate_proof(packet.data) self.watchdog_lock = False diff --git a/RNS/Packet.py b/RNS/Packet.py index bd7c7b7..f4dd4ba 100755 --- a/RNS/Packet.py +++ b/RNS/Packet.py @@ -70,7 +70,7 @@ class Packet: self.destination = destination self.transport_id = transport_id self.data = data - self.flags = self.getPackedFlags() + self.flags = self.get_packed_flags() self.raw = None self.packed = False @@ -91,7 +91,7 @@ class Packet: self.attached_interface = attached_interface self.receiving_interface = None - def getPackedFlags(self): + def get_packed_flags(self): if self.context == Packet.LRPROOF: packed_flags = (self.header_type << 6) | (self.transport_type << 4) | RNS.Destination.LINK | self.packet_type else: @@ -230,14 +230,14 @@ class Packet: # Generates a special destination that allows Reticulum # to direct the proof back to the proved packet's sender - def generateProofDestination(self): + def generate_proof_destination(self): return ProofDestination(self) - def validateProofPacket(self, proof_packet): - return self.receipt.validateProofPacket(proof_packet) + def validate_proof_packet(self, proof_packet): + return self.receipt.validate_proof_packet(proof_packet) - def validateProof(self, proof): - return self.receipt.validateProof(proof) + def validate_proof(self, proof): + return self.receipt.validate_proof(proof) def updateHash(self): self.packet_hash = self.getHash() @@ -290,11 +290,11 @@ class PacketReceipt: self.concluded_at = None # Validate a proof packet - def validateProofPacket(self, proof_packet): + def validate_proof_packet(self, proof_packet): if hasattr(proof_packet, "link") and proof_packet.link: return self.validate_link_proof(proof_packet.data, proof_packet.link) else: - return self.validateProof(proof_packet.data) + return self.validate_proof(proof_packet.data) # Validate a raw proof for a link def validate_link_proof(self, proof, link): @@ -336,7 +336,7 @@ class PacketReceipt: return False # Validate a raw proof - def validateProof(self, proof): + def validate_proof(self, proof): if len(proof) == PacketReceipt.EXPL_LENGTH: # This is an explicit proof proof_hash = proof[:RNS.Identity.HASHLENGTH//8] diff --git a/RNS/Resource.py b/RNS/Resource.py index 2f2a695..5eefd4f 100644 --- a/RNS/Resource.py +++ b/RNS/Resource.py @@ -483,7 +483,7 @@ class Resource: RNS.log("The contained exception was: "+str(e), RNS.LOG_DEBUG) self.cancel() - def validateProof(self, proof_data): + def validate_proof(self, proof_data): if not self.status == Resource.FAILED: if len(proof_data) == RNS.Identity.HASHLENGTH//8*2: if proof_data[RNS.Identity.HASHLENGTH//8:] == self.expected_proof: diff --git a/RNS/Transport.py b/RNS/Transport.py index ebd0d84..f8076e9 100755 --- a/RNS/Transport.py +++ b/RNS/Transport.py @@ -862,11 +862,11 @@ class Transport: if proof_hash != None: # Only test validation if hash matches if receipt.hash == proof_hash: - receipt_validated = receipt.validateProofPacket(packet) + receipt_validated = receipt.validate_proof_packet(packet) else: # In case of an implicit proof, we have # to check every single outstanding receipt - receipt_validated = receipt.validateProofPacket(packet) + receipt_validated = receipt.validate_proof_packet(packet) if receipt_validated: Transport.receipts.remove(receipt)