| 857 | |
| 858 | |
| 859 | PacketReceipt::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 |
| 883 | bool PacketReceipt::validate_proof_packet(const Packet& proof_packet) { |
nothing calls this directly
no test coverage detected