mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-22 21:50:18 +00:00
Refactored Packet method names
This commit is contained in:
parent
cd2f49272d
commit
55c0f44e58
@ -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()
|
||||
|
@ -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
|
||||
|
||||
|
@ -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]
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user