MCPcopy Create free account
hub / github.com/attermann/microReticulum / PacketReceipt

Method PacketReceipt

src/microReticulum/Packet.cpp:859–880  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

857
858
859PacketReceipt::PacketReceipt(const Packet& packet) : _object(new Object()) {
860
861 if (!packet.destination()) {
862 throw std::invalid_argument("Packet with destination is required");
863 }
864 _object->_hash = packet.get_hash();
865 _object->_truncated_hash = packet.getTruncatedHash();
866 _object->_destination = packet.destination();
867
868 // CBA LINK
869 if (packet.destination().type() == Type::Destination::LINK) {
870 if (!packet.destination_link()) throw std::invalid_argument("Packet is not associated with a Link");
871 //p self.timeout = max(packet.destination.rtt * packet.destination.traffic_timeout_factor, RNS.Link.TRAFFIC_TIMEOUT_MIN_MS/1000)
872 _object->_timeout = std::max(packet.destination_link().rtt() * packet.destination_link().traffic_timeout_factor(), (double)RNS::Type::Link::TRAFFIC_TIMEOUT_MIN_MS/1000);
873 }
874 else {
875 //p self.timeout = RNS.Reticulum.get_instance().get_first_hop_timeout(self.destination.hash)
876 //p self.timeout += Packet.TIMEOUT_PER_HOP * RNS.Transport.hops_to(self.destination.hash)
877 _object->_timeout = RNS::Reticulum::get_instance().get_first_hop_timeout(_object->_destination.hash());
878 _object->_timeout += TIMEOUT_PER_HOP * Transport::hops_to(_object->_destination.hash());
879 }
880}
881
882// Validate a proof packet
883bool PacketReceipt::validate_proof_packet(const Packet& proof_packet) {

Callers

nothing calls this directly

Calls 8

destinationMethod · 0.80
getTruncatedHashMethod · 0.80
rttMethod · 0.80
get_first_hop_timeoutMethod · 0.80
hashMethod · 0.80
get_hashMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected