diff --git a/crates/lxmf-core/src/constants.rs b/crates/lxmf-core/src/constants.rs index 882f2a9..b79c49d 100644 --- a/crates/lxmf-core/src/constants.rs +++ b/crates/lxmf-core/src/constants.rs @@ -18,21 +18,21 @@ pub const FIELD_TICKET: u8 = 0x0C; pub const FIELD_EVENT: u8 = 0x0D; pub const FIELD_RNR_REFS: u8 = 0x0E; pub const FIELD_RENDERER: u8 = 0x0F; -/// Bytes, full `LXMessage` hash. Python reference: LXMF.py:23. +/// Bytes, full `LXMessage` hash. Python reference: LXMF.py. pub const FIELD_REPLY_TO: u8 = 0x30; -/// Bytes, quoted content in UTF-8 encoding. Python reference: LXMF.py:24. +/// Bytes, quoted content in UTF-8 encoding. Python reference: LXMF.py. pub const FIELD_REPLY_QUOTE: u8 = 0x31; -/// Dict keyed by [`REACTION_TO`] / [`REACTION_CONTENT`]. Python reference: LXMF.py:25. +/// Dict keyed by [`REACTION_TO`] / [`REACTION_CONTENT`]. Python reference: LXMF.py. pub const FIELD_REACTION: u8 = 0x40; -/// Dict keyed by [`COMMENT_FOR`]. Python reference: LXMF.py:26. +/// Dict keyed by [`COMMENT_FOR`]. Python reference: LXMF.py. pub const FIELD_COMMENT: u8 = 0x41; -/// Dict keyed by [`CONTINUATION_OF`]. Python reference: LXMF.py:27. +/// Dict keyed by [`CONTINUATION_OF`]. Python reference: LXMF.py. pub const FIELD_CONTINUATION: u8 = 0x42; // Unallocated fields between 0x00 and 0x80, both included, should be // considered reserved for future extensibility. For experimental and // unstable features, it is recommended to use fields above 0xFF. -// Python reference: LXMF.py:29-32. +// Python reference: LXMF.py. pub const FIELD_CUSTOM_TYPE: u8 = 0xFB; pub const FIELD_CUSTOM_DATA: u8 = 0xFC; @@ -69,7 +69,7 @@ pub const RENDERER_BBCODE: u8 = 0x03; // Clients choose how to handle reaction content, if at all. While reactions // are typically a single unicode emoji or similar, the exact implementation // and sanitization is left up to the client. FIELD_REACTION dict keys — -// Python reference: LXMF.py:104-110. +// Python reference: LXMF.py. /// Bytes, full `LXMessage` hash. pub const REACTION_TO: u8 = 0x00; /// Bytes, the reaction content in UTF-8 encoding. @@ -77,13 +77,13 @@ pub const REACTION_CONTENT: u8 = 0x01; // Comment content is carried as the normal LXM content, so clients that do // not support comments display them as normal messages. FIELD_COMMENT dict -// key — Python reference: LXMF.py:112-118. +// key — Python reference: LXMF.py. /// Bytes, full `LXMessage` hash. pub const COMMENT_FOR: u8 = 0x00; // Continuation content is carried as the normal LXM content, so clients that // do not support continuations display them as normal messages. -// FIELD_CONTINUATION dict key — Python reference: LXMF.py:120-126. +// FIELD_CONTINUATION dict key — Python reference: LXMF.py. /// Bytes, full `LXMessage` hash. pub const CONTINUATION_OF: u8 = 0x00; @@ -193,9 +193,9 @@ pub const PROPAGATION_LIMIT: usize = 256; pub const DELIVERY_LIMIT: usize = 1000; /// PROPAGATION_LIMIT * 40, in KB. pub const SYNC_LIMIT: usize = 10240; -/// Link-request stamp cost announced by delivery destinations (LXMRouter.py:53). +/// Link-request stamp cost announced by delivery destinations (LXMRouter.py). pub const DELIVERY_LINK_COST: f64 = 3.25; -/// Link-request stamp cost announced by propagation destinations (LXMRouter.py:54). +/// Link-request stamp cost announced by propagation destinations (LXMRouter.py). pub const PROPAGATION_LINK_COST: f64 = 3.25; pub const PROPAGATION_COST_MIN: f64 = 13.0; pub const PROPAGATION_COST: f64 = 16.0; @@ -310,7 +310,7 @@ mod tests { assert_eq!(LXMF_OVERHEAD, 112); } - /// LXMF 1.2.0 `ENCRYPTED_PACKET_MAX_CONTENT` (LXMessage.py:64-79, 3fc60af). + /// LXMF 1.2.0 `ENCRYPTED_PACKET_MAX_CONTENT` (LXMessage.pyfc60af). #[test] fn encrypted_packet_max_content_is_lxmf_1_2_0s() { assert_eq!(ENCRYPTED_PACKET_MAX_CONTENT, 287); @@ -409,7 +409,7 @@ mod tests { #[test] fn test_field_standards_match_python_101() { - // LXMF.py:23-27 field allocations plus dict-key constants (LXMF.py:104-126). + // LXMF.py field allocations plus dict-key constants (LXMF.py). assert_eq!(FIELD_REPLY_TO, 0x30); assert_eq!(FIELD_REPLY_QUOTE, 0x31); assert_eq!(FIELD_REACTION, 0x40); diff --git a/crates/lxmf-core/src/discovery_stamper.rs b/crates/lxmf-core/src/discovery_stamper.rs index 7f716a9..55c8a53 100644 --- a/crates/lxmf-core/src/discovery_stamper.rs +++ b/crates/lxmf-core/src/discovery_stamper.rs @@ -1,6 +1,6 @@ //! Stamper for Reticulum interface discovery. //! -//! Upstream's discovery stamper is `RNS.Stamps` (Discovery.py:87,266); +//! Upstream's discovery stamper is `RNS.Stamps` (Discovery.py); //! [`LxmfDiscoveryStamper`] delegates to //! `rns_transport::discovery::RnsDiscoveryStamper` for callers that install it. use rns_transport::discovery::DiscoveryStamper; diff --git a/crates/lxmf-core/src/handlers.rs b/crates/lxmf-core/src/handlers.rs index 1e1331b..16f457a 100644 --- a/crates/lxmf-core/src/handlers.rs +++ b/crates/lxmf-core/src/handlers.rs @@ -50,8 +50,8 @@ pub enum CompressionSupport { } /// A per-transfer or per-sync limit as Python holds it: lxmd's built-in defaults -/// are ints, configured values come from `as_float` (lxmd.py:165-184@1.3.0), -/// and the announce packs whichever it has (LXMRouter.py:394-395). +/// are ints, configured values come from `as_float` (lxmd.py), +/// and the announce packs whichever it has (LXMRouter.py). #[derive(Debug, Clone, Copy, PartialEq)] pub enum PnLimit { Int(u64), @@ -462,7 +462,7 @@ pub fn parse_pn_announce_data(data: &[u8]) -> Option Option { let raw = python_index(&value, index)?; let int = python_int(&raw)?; @@ -965,7 +965,7 @@ impl PropagationRequestHandler { /// Compile propagation-node statistics as msgpack. /// - /// Python reference: `LXMRouter.compile_stats` — LXMRouter.py:750-817. + /// Python reference: `LXMRouter.compile_stats` — LXMRouter.py. fn compile_stats( &self, node: &crate::propagation_node::PropagationNode, @@ -1364,7 +1364,7 @@ mod tests { #[test] fn test_compression_support_from_app_data() { // Legacy <=0.9.8 2-element app_data: unknown state, fail-open true - // (Python returns True for len < 3 — LXMF.py:161). + // (Python returns True for len < 3 — LXMF.py). let python_098 = { use rmpv::Value; let arr = Value::Array(vec![Value::Binary(b"Alice".to_vec()), Value::from(12u64)]); @@ -1426,7 +1426,7 @@ mod tests { assert!(!compression_support_from_app_data(&empty_features)); // Malformed data: unknown state, fail-open true (Python treats the - // original non-msgpack announce format as supported — LXMF.py:167). + // original non-msgpack announce format as supported — LXMF.py). assert_eq!( compression_support_state_from_app_data(&[0xc1]), CompressionSupport::Unknown diff --git a/crates/lxmf-core/src/link_delivery.rs b/crates/lxmf-core/src/link_delivery.rs index 0be1139..f8d8c9f 100644 --- a/crates/lxmf-core/src/link_delivery.rs +++ b/crates/lxmf-core/src/link_delivery.rs @@ -394,7 +394,7 @@ pub struct PendingDelivery { endpoint_release_queued: bool, /// Keep successful links open for additional messages. pub reusable: bool, - /// Upload link to a propagation node; never identified (LXMRouter.py:3283-3287). + /// Upload link to a propagation node; never identified (LXMRouter.py). propagation_upload: bool, /// Whether local Link identification was staged after a successful Direct /// delivery. Requires configured identity keys; it is not a peer acknowledgement. @@ -408,7 +408,7 @@ pub struct PendingDelivery { inbound_split_resources: HashMap<[u8; 32], MultiSegmentInbound>, inbound_segment_routing: HashMap<[u8; 32], InboundSegmentRoute>, inbound_resource_lifecycles: HashMap<[u8; 32], InboundResourceLifecycle>, - /// `Link.last_resource_window` and `last_resource_eifr` (Link.py:1344-1348). + /// `Link.last_resource_window` and `last_resource_eifr` (Link.py). last_inbound_resource: Option<(usize, Option)>, } @@ -1014,7 +1014,7 @@ impl LinkDeliveryManager { /// Record Transport's answer to `GetNextHopHardwareMtu` for `dest_hash` /// (`None` for no answer); the next Link opened to it signals that MTU - /// while the stamper's `link_mtu_discovery` is on (Link.py:392-397@1.6.0). + /// while the stamper's `link_mtu_discovery` is on (Link.py). pub fn provide_next_hop_hardware_mtu(&mut self, dest_hash: [u8; 16], mtu: Option) { match mtu.filter(|mtu| *mtu != 0) { Some(mtu) => { @@ -1367,7 +1367,7 @@ impl LinkDeliveryManager { timing: LinkEstablishmentTiming, ) -> Result { let started = self.start_direct_delivery(message, dest_hash, hops, timing); - // Keys belong to one Link request (Link.py:313-316); never carry them to a later one. + // Keys belong to one Link request (Link.py); never carry them to a later one. self.prepared_link_keys.remove(&dest_hash); started } @@ -2214,7 +2214,7 @@ impl LinkDeliveryManager { ); continue; } - // Link.py:1030; packet proofs reach the Link only as receipts (Transport.py:2997-3036). + // Link.py; packet proofs reach the Link only as receipts (Transport.py). let link_receives = header.flags.packet_type != rns_wire::flags::PacketType::Proof || header.context == rns_wire::context::PacketContext::ResourcePrf; @@ -2344,7 +2344,7 @@ impl LinkDeliveryManager { } } rns_wire::context::PacketContext::ResourcePrf => { - // PROOF+RESOURCE_PRF is plaintext on a Proof packet (Packet.py:195-197). + // PROOF+RESOURCE_PRF is plaintext on a Proof packet (Packet.py). // Body = resource_hash(32) || proof(32); pass through without decrypt. self.handle_resource_proof(&link_id, data); } @@ -2710,7 +2710,7 @@ impl LinkDeliveryManager { notify_inbound_resource_concluded(concluded_handler.as_ref(), *link_id, resource_id); return false; }; - // Receiver timing uses the link's SDU (Resource.py:346-347@1.6.0). + // Receiver timing uses the link's SDU (Resource.py). transfer.resource.sdu = delivery.link.resource_sdu(); let action = transfer.request_next(); @@ -2835,7 +2835,7 @@ impl LinkDeliveryManager { .get_mut(&resource_hash) .map(|transfer| transfer.complete(Some(&decrypt))) }; - // Link.resource_concluded runs after assembly whatever its outcome (Resource.py:740). + // Link.resource_concluded runs after assembly whatever its outcome (Resource.py). if let Some(transfer) = delivery.inbound_resources.get(&resource_hash) { delivery.last_inbound_resource = Some((transfer.resource.window.window, transfer.eifr)); } @@ -3222,9 +3222,9 @@ impl LinkDeliveryManager { } else { delivery.message.representation = DeliveryRepresentation::Resource; // Python's Resource encrypts the blob with link session keys - // BEFORE chunking (Resource.py:424), and resource parts are sent + // BEFORE chunking (Resource.py), and resource parts are sent // on the wire WITHOUT additional packet-layer encryption - // (Packet.py:201-204). + // (Packet.py). let rtt = delivery.link.rtt.unwrap_or(Duration::from_millis(500)); let auto_compress = if delivery.packed_override.is_some() { delivery.auto_compress @@ -5611,7 +5611,7 @@ fn build_resource_transfer( } /// An outbound Resource on `link`: parts sized by the link's SDU and the -/// advertisement bounded by its MDU (Resource.py:346-347, :542@1.6.0). +/// advertisement bounded by its MDU (Resource.py). pub(crate) fn link_transfer( link: &Link, resource: OutboundResource, @@ -5633,7 +5633,7 @@ pub(crate) fn answered_hardware_mtu( } } -/// The MTU a new link request signals (Link.py:392-397@1.6.0): the next hop's +/// The MTU a new link request signals (Link.py): the next hop's /// hardware MTU when discovery is on and Transport reported one, else the base MTU. pub(crate) fn signalled_link_mtu(stamper: &LinkRequestStamper, next_hop_mtu: Option) -> u32 { next_hop_mtu @@ -6033,7 +6033,7 @@ fn drive_inbound_resource_watchdogs( let resource_id = drop_inbound_resource(delivery, resource_hash); notify_inbound_resource_concluded(concluded_handler, *link_id, resource_id); } - // Resource.cancel() sends RCL only on an active Link (Resource.py:1133-1139). + // Resource.cancel() sends RCL only on an active Link (Resource.py). TransferAction::SendCancel(_, _) if delivery.link.state != LinkState::Active => {} retry => { if dispatch_inbound_resource_action( @@ -6256,7 +6256,7 @@ fn dispatch_action( } TransferAction::SendPart(_, part_data) => { // Parts are already ciphertext (pre-chunk blob encryption). `context=Resource` - // packets are not packet-layer encrypted (Packet.py:201-204). + // packets are not packet-layer encrypted (Packet.py). if let Err(reason) = send( make_header( rns_wire::context::PacketContext::Resource, @@ -6303,7 +6303,7 @@ fn dispatch_action( ActionOutcome::Continue } TransferAction::SendProof(proof_data) => { - // PROOF+RESOURCE_PRF is plaintext on a Proof packet (Packet.py:195-197). Body = + // PROOF+RESOURCE_PRF is plaintext on a Proof packet (Packet.py). Body = // resource_hash(32) || proof(32). if let Err(reason) = send( make_header( @@ -6327,7 +6327,7 @@ fn dispatch_action( ActionOutcome::Fail(reason) } TransferAction::SendCancel(cancel_type, resource_hash) => { - // Resource.cancel() sends ICL/RCL only on an active Link (Resource.py:1126, 1134). + // Resource.cancel() sends ICL/RCL only on an active Link (Resource.py). let active = delivery.link.state == LinkState::Active; if let Some(encrypted) = active .then(|| delivery.link.encrypt(&resource_hash).ok()) diff --git a/crates/lxmf-core/src/persist.rs b/crates/lxmf-core/src/persist.rs index 9f9e571..05df789 100644 --- a/crates/lxmf-core/src/persist.rs +++ b/crates/lxmf-core/src/persist.rs @@ -515,7 +515,7 @@ mod tests { write_file_atomic(&path, b"first").unwrap(); assert_eq!(fs::read(&path).unwrap(), b"first"); - // Replaces existing content (os.replace semantics — LXMessage.py:687). + // Replaces existing content (os.replace semantics — LXMessage.py). write_file_atomic(&path, b"second").unwrap(); assert_eq!(fs::read(&path).unwrap(), b"second"); @@ -532,7 +532,7 @@ mod tests { fn write_file_atomic_cleans_tmp_on_error() { let tmp = TempDir::new().unwrap(); // Destination is a directory: the final rename fails, and the tmp - // file must be unlinked (LXMessage.py:691-693). + // file must be unlinked (LXMessage.py). let dir_path = tmp.path().join("collide"); fs::create_dir(&dir_path).unwrap(); diff --git a/crates/lxmf-core/src/propagation_client.rs b/crates/lxmf-core/src/propagation_client.rs index e90737a..5d5429f 100644 --- a/crates/lxmf-core/src/propagation_client.rs +++ b/crates/lxmf-core/src/propagation_client.rs @@ -265,7 +265,7 @@ pub struct PropagationClient { link_stamper: LinkRequestStamper, prepared_link_keys: Option<([u8; 16], EphemeralKeys)>, mtu_query: Option>, - /// `Link.last_resource_window` and `last_resource_eifr` (Link.py:1344-1348). + /// `Link.last_resource_window` and `last_resource_eifr` (Link.py). last_inbound_resource: Option<(usize, Option)>, /// Phase 1 response: transient IDs the server has. available_messages: Vec>, @@ -1251,7 +1251,7 @@ impl PropagationClient { } else { &[] }; - // Link.py:1030; packet proofs reach the Link only as receipts (Transport.py:2997-3036). + // Link.py; packet proofs reach the Link only as receipts (Transport.py). let link_receives = header.flags.packet_type != rns_wire::flags::PacketType::Proof || header.context == rns_wire::context::PacketContext::ResourcePrf; @@ -2181,7 +2181,7 @@ impl PropagationClient { } DownloadAdmissionOutcome::Rejected(reason) => { // Python purges every downloaded message, whatever lxmf_propagation - // did (LXMRouter.py:1838-1853). A message that failed for a passing + // did (LXMRouter.py). A message that failed for a passing // local reason stays on the node so the next sync can fetch it again. if !reason.is_transient() { self.rejected_ids.push(result.scope.transient_id.to_vec()); @@ -2350,7 +2350,7 @@ impl PropagationClient { ); } if let Some(hash) = cancel { - // Resource.cancel() sends RCL only on an active Link (Resource.py:1133-1139). + // Resource.cancel() sends RCL only on an active Link (Resource.py). if self .link .as_ref() @@ -2713,7 +2713,7 @@ impl PropagationClient { ); } Some(TransferAction::SendCancel(_, hash)) => { - // Resource.cancel() sends ICL only on an active Link (Resource.py:1124-1132). + // Resource.cancel() sends ICL only on an active Link (Resource.py). if self .link .as_ref() diff --git a/crates/lxmf-core/src/propagation_node.rs b/crates/lxmf-core/src/propagation_node.rs index 859e579..4c4ad99 100644 --- a/crates/lxmf-core/src/propagation_node.rs +++ b/crates/lxmf-core/src/propagation_node.rs @@ -2361,7 +2361,7 @@ pub(crate) mod tests { } /// T0-1: `/get` ownership gating — a client may only list, download, and - /// purge messages addressed to itself (Python LXMRouter.py:1454/1479). + /// purge messages addressed to itself (Python LXMRouter.py/1479). #[test] fn test_get_request_ownership_gating() { use rmpv::Value; @@ -3578,7 +3578,7 @@ pub(crate) mod tests { } /// T2-8b parity: haves are purged before wants resolve (Python - /// LXMRouter.py:1451-1462) — an ID in both is purged, not served. + /// LXMRouter.py) — an ID in both is purged, not served. #[test] fn test_get_phase_purges_haves_before_serving_wants() { use rmpv::Value; @@ -3615,7 +3615,7 @@ pub(crate) mod tests { /// T2-8b parity: transfer limit is kB ×1000 with 24-byte base and 16-byte /// per-message overhead, and over-limit entries are skipped rather than - /// aborting the serve loop (Python LXMRouter.py:1471-1494). + /// aborting the serve loop (Python LXMRouter.py). #[test] fn test_get_phase_transfer_limit_python_accounting() { use rmpv::Value; @@ -3666,7 +3666,7 @@ pub(crate) mod tests { } /// T2-8b parity: phase-1 listing is sorted smallest message first - /// (Python LXMRouter.py:1437-1444). + /// (Python LXMRouter.py). #[test] fn test_get_list_phase_sorted_smallest_first() { use rmpv::Value; diff --git a/crates/lxmf-core/src/propagation_sync.rs b/crates/lxmf-core/src/propagation_sync.rs index 2138018..85d7324 100644 --- a/crates/lxmf-core/src/propagation_sync.rs +++ b/crates/lxmf-core/src/propagation_sync.rs @@ -128,7 +128,7 @@ fn prepare_outbound_resource_transfers( link_sdu: usize, link_mdu: usize, ) -> Result, ResourceError> { - // Parts follow the link's SDU and advertisements its MDU (Resource.py:346-347, :542@1.6.0). + // Parts follow the link's SDU and advertisements its MDU (Resource.py). let encrypt = |plaintext: &[u8]| { rns_link::encryption::link_encrypt(&link_keys, plaintext) .unwrap_or_else(|_| plaintext.to_vec()) @@ -859,7 +859,7 @@ impl PropagationSyncTask { } rns_wire::context::PacketContext::ResourcePrf => { // Python Packet.pack() sends PROOF+RESOURCE_PRF as - // plaintext (Packet.py:195-197) on PacketType::Proof. + // plaintext (Packet.py) on PacketType::Proof. // Body = resource_hash(32) || proof(32). let completed = self .active_transfer @@ -1101,7 +1101,7 @@ impl PropagationSyncTask { } } - /// Python reference: LXMPeer.py:396-439 (offer_response). + /// Python reference: LXMPeer.py (offer_response). fn handle_offer_response(&mut self, response: OfferResponse) { let node_hash = match self.node_dest_hash { Some(h) => h, @@ -1367,7 +1367,7 @@ impl PropagationSyncTask { } } - /// Python reference: LXMPeer.py:381-386. + /// Python reference: LXMPeer.py. fn send_offer_request(&mut self) { let node_hash = match self.node_dest_hash { Some(h) => h, @@ -1855,7 +1855,7 @@ impl PropagationSyncTask { break; } TransferAction::SendCancel(_, resource_hash) => { - // Resource.cancel() sends ICL only on an active Link (Resource.py:1124-1132). + // Resource.cancel() sends ICL only on an active Link (Resource.py). if self .link .as_ref() @@ -2022,7 +2022,7 @@ impl PropagationSyncTask { }) } - /// Python LXMPeer.py:540-542. + /// Python LXMPeer.py. fn cleanup_sync(&mut self) { self.link_request_result = None; self.path_query = None; diff --git a/crates/lxmf-core/src/router.rs b/crates/lxmf-core/src/router.rs index e5903dc..d5b74d0 100644 --- a/crates/lxmf-core/src/router.rs +++ b/crates/lxmf-core/src/router.rs @@ -736,7 +736,7 @@ impl LxmRouter { } /// The oldest deferred message, as Python's insertion-ordered dict yields - /// it (LXMRouter.py:2655-2662). + /// it (LXMRouter.py). fn next_deferred_stamp(&mut self) -> Option<[u8; 32]> { while let Some(id) = self.deferred_stamp_order.front() { if self.pending_deferred_stamps.contains_key(id) { @@ -1161,7 +1161,7 @@ impl LxmRouter { /// Destinations that received a delivered message since the last call. /// /// Python's router retains each one's announce data in Reticulum so its - /// identity outlives its path (LXMRouter.py:2761). Send each as + /// identity outlives its path (LXMRouter.py). Send each as /// `TransportQuery::RetainDestination` through the control plane, which /// forwards to a shared instance. Up to 256 distinct destinations are kept /// in insertion order; a repeat delivery does not refresh an existing entry's position. @@ -1252,7 +1252,7 @@ impl LxmRouter { /// effects or record a distinct ciphertext transient ID. Use the reservation /// and durable-receipt commit path for application admission. pub fn deliver_inbound(&mut self, message: &LxMessage, allow_duplicate: bool) -> bool { - // LXMRouter.py:2231-2233: ignored sources are dropped before dedup. + // LXMRouter.py: ignored sources are dropped before dedup. if self.is_ignored(&message.source_hash()) { return false; } @@ -1408,7 +1408,7 @@ impl LxmRouter { let mut packed = destination_hash.to_vec(); packed.extend_from_slice(&decrypt_fn(&encrypted)?); // Python records the transient id as delivered even when the decrypted - // bytes do not unpack (LXMRouter.py:2858-2864). + // bytes do not unpack (LXMRouter.py). let unpacked = LxMessage::unpack(&packed); self.claim_locally_delivered(transient_id); let mut message = unpacked?; @@ -1462,7 +1462,7 @@ impl LxmRouter { self.client_propagation_messages_served = stats.client_propagation_messages_served; self.unpeered_propagation_incoming = stats.unpeered_propagation_incoming; self.unpeered_propagation_rx_bytes = stats.unpeered_propagation_rx_bytes; - // Python cleans transient IDs, tickets and stamp costs at load (LXMRouter.py:292-297). + // Python cleans transient IDs, tickets and stamp costs at load (LXMRouter.py). let now = now_f64(); self.propagation_store.clean_transient_caches(now); self.ticket_store.cull(now); @@ -1578,7 +1578,7 @@ impl LxmRouter { } = candidate; let configured_static = self.static_peers.contains(&destination_hash); - // Python LXMRouter.peer() (LXMRouter.py:1896-1901): a peering cost + // Python LXMRouter.peer() (LXMRouter.py): a peering cost // above our accepted maximum refuses the peering — and breaks an // existing one only when that policy announce is not stale. if peering_cost.unwrap_or(0.0) > self.config.ext.max_peering_cost { @@ -3879,7 +3879,7 @@ mod tests { } /// LXMF keeps a message opportunistic only while its content fits - /// one encrypted packet, 287 bytes (LXMessage.py:64-79, :402-406). + /// one encrypted packet, 287 bytes (LXMessage.py). #[test] fn opportunistic_content_over_one_packet_falls_back_to_direct() { let mut router = LxmRouter::new(RouterConfig::default()); @@ -3926,7 +3926,7 @@ mod tests { } /// Python fails a message only when delivery_attempts > MAX_DELIVERY_ATTEMPTS - /// (outer guard is `<= MAX`, LXMRouter.py:2597/2671). Pin that boundary. + /// (outer guard is `<= MAX`, LXMRouter.py/2671). Pin that boundary. #[test] fn test_process_outbound_fails_only_above_max_attempts() { let mut router = LxmRouter::new(RouterConfig::default()); @@ -4369,7 +4369,7 @@ mod tests { /// T0-4: peering cost above `max_peering_cost` refuses peering, and an /// existing peering breaks when the peer raises its cost beyond the cap - /// (Python LXMRouter.py:1896-1901). + /// (Python LXMRouter.py). #[test] fn test_autopeer_enforces_max_peering_cost() { let mut router = LxmRouter::new(RouterConfig::default()); @@ -4559,7 +4559,7 @@ mod tests { router.tick(); - // Without a known path the router only asks for one (LXMRouter.py:3229-3233). + // Without a known path the router only asks for one (LXMRouter.py). assert!(matches!( rx.try_recv(), Ok(rns_transport::messages::TransportMessage::RequestPath { .. }) @@ -4757,7 +4757,7 @@ mod tests { assert_eq!(router.pending_outbound.len(), 1); } - /// Python's deferred-stamp dict keeps insertion order (LXMRouter.py:2655-2662). + /// Python's deferred-stamp dict keeps insertion order (LXMRouter.py). #[test] fn deferred_stamps_are_generated_in_submission_order() { let (identity, source) = resumable_sender(); @@ -4794,7 +4794,7 @@ mod tests { } /// Python retains a destination's announce data once a message to it is - /// delivered (LXMRouter.py:2761). + /// delivered (LXMRouter.py). #[test] fn delivered_messages_ask_to_retain_their_destination() { let mut router = LxmRouter::new(RouterConfig::default()); diff --git a/crates/lxmf-core/src/router/outbound.rs b/crates/lxmf-core/src/router/outbound.rs index 4e6f16b..72a7399 100644 --- a/crates/lxmf-core/src/router/outbound.rs +++ b/crates/lxmf-core/src/router/outbound.rs @@ -123,8 +123,8 @@ pub fn schedule_attempt(message: &mut LxMessage, round_trip: f64, path_request: } /// Timeout for an opportunistic delivery receipt: the RNS packet receipt -/// timeout (Packet.py:429-433), raised to the message's airtime-aware -/// `receipt_timeout` (LXMessage.py:482). Without a route Reticulum counts +/// timeout (Packet.py), raised to the message's airtime-aware +/// `receipt_timeout` (LXMessage.py). Without a route Reticulum counts /// `PATHFINDER_M` hops. pub fn opportunistic_receipt_timeout( route: Option, diff --git a/crates/lxmf-tools/src/commands/lxmd.rs b/crates/lxmf-tools/src/commands/lxmd.rs index 5c9099e..143ea8e 100644 --- a/crates/lxmf-tools/src/commands/lxmd.rs +++ b/crates/lxmf-tools/src/commands/lxmd.rs @@ -1141,7 +1141,7 @@ fn link_snapshot_state( } /// Python `lxmf_delivery()` receive state: the delivery method, and Curve25519 -/// transport encryption for SINGLE and LINK destinations (LXMRouter.py:2174,2218-2226). +/// transport encryption for SINGLE and LINK destinations (LXMRouter.py). fn mark_received(msg: &mut LxMessage, method: DeliveryMethod) { let destination_type = match method { DeliveryMethod::Direct => rns_wire::flags::DestinationType::Link, @@ -1182,7 +1182,7 @@ fn direct_reusable_link_state( } } -/// Python `Transport.medium_path_timeout()` for a known bitrate (Transport.py:3550-3553). +/// Python `Transport.medium_path_timeout()` for a known bitrate (Transport.py). fn medium_path_timeout(lowest_bitrate: u64) -> f64 { let bits = (rns_wire::constants::MTU * 8) as f64; 2.0 * (bits / lowest_bitrate.max(rns_runtime::constants::MINIMUM_BITRATE) as f64) @@ -1190,7 +1190,7 @@ fn medium_path_timeout(lowest_bitrate: u64) -> f64 { } /// Drop the current path, then request a new one 0.5 s later, as Python's -/// opportunistic rediscovery does (LXMRouter.py:3127-3133). +/// opportunistic rediscovery does (LXMRouter.py). fn queue_path_request_after_drop( transport_tx: &mpsc::Sender, destination: [u8; 16], @@ -1367,7 +1367,7 @@ struct PeerPathCheck { const JOBS_INTERVAL: u64 = 5; /// Resolve a destination hash to its identity hash via the learned identity -/// keys — the lxmd equivalent of `RNS.Identity.recall` (LXMessage.py:776). +/// keys — the lxmd equivalent of `RNS.Identity.recall` (LXMessage.py). /// Identity hash = truncated hash of the 64-byte announce public key. fn recall_identity_hash( known_identities: &HashMap, @@ -1454,7 +1454,7 @@ fn dispatch_opportunistic_packet( Ok(()) } -/// `LXMessage.unpack_from_bytes` signature flags (LXMessage.py:829-842). +/// `LXMessage.unpack_from_bytes` signature flags (LXMessage.py). fn classify_signature( msg: &LxMessage, public_key: Option<&[u8; 64]>, @@ -1675,7 +1675,7 @@ struct LxmdRunner { retain_task: Option>, route_hops: HashMap<[u8; 16], u8>, /// Transport blackhole table snapshot, refreshed per tick. Used to drop - /// inbound LXMs from blackholed identities (LXMRouter.py:1739-1741). + /// inbound LXMs from blackholed identities (LXMRouter.py). blackholed_identities: HashSet<[u8; 16]>, link_delivery: Option, link_command_tx: mpsc::Sender, @@ -1841,7 +1841,7 @@ impl LxmdRunner { /// Learn the LXMF identities Transport validated before these /// subscriptions existed; later ones arrive as announce events. Python's - /// LXMF recalls them from `RNS.Identity` (Transport.py:2172). + /// LXMF recalls them from `RNS.Identity` (Transport.py). async fn learn_validated_identities(&mut self) { let (response_tx, response_rx) = oneshot::channel(); let query = TransportMessage::Rpc { @@ -1928,7 +1928,7 @@ impl LxmdRunner { /// Retain delivered destinations in Reticulum, through the shared /// instance when attached to one, as Python's router does - /// (LXMRouter.py:2761, Reticulum.py:1449-1461). + /// (LXMRouter.py, Reticulum.py). fn forward_destination_retains(&mut self) { let Some(control_plane) = self.control_plane.clone() else { return; @@ -2588,7 +2588,7 @@ impl LxmdRunner { std::fs::create_dir_all(&messages_dir)?; // Upstream's messages directory holds only write_to_directory containers - // (lxmd.py:302-307@1.3.0); the admission store keeps its raw bodies privately. + // (lxmd.py); the admission store keeps its raw bodies privately. let admission_store = match FileAdmissionStore::open_moving_bodies_from( &paths.router_state_dir, &paths.router_state_dir.join(ADMISSION_BODIES_DIR), @@ -2915,7 +2915,7 @@ impl LxmdRunner { kind: DeliveryAnnounceKind<'_>, stamp_ext: Option<&AnnounceStampExt>, ) -> Result, DeliveryRatchetError> { - // Path responses carry the default app data, which LXMRouter.py:431-434 sets only with a display name. + // Path responses carry the default app data, which LXMRouter.py sets only with a display name. let app_data = match (kind, self.config.display_name.as_deref()) { (DeliveryAnnounceKind::PathResponse { .. }, None) => Vec::new(), (_, name) => delivery_announce_app_data(name, self.config.stamp_cost), @@ -3865,7 +3865,7 @@ impl LxmdRunner { /// Snapshot the transport blackhole table. Ungated: the table is tiny and /// the per-tick roundtrip keeps drops close to Python's live - /// `Reticulum.is_blackholed` query (LXMessage.py:803-805). Fail-open: on + /// `Reticulum.is_blackholed` query (LXMessage.py). Fail-open: on /// query failure the previous snapshot stays in effect. async fn refresh_blackholed_identities_from_transport(&mut self) { let (response_tx, response_rx) = tokio::sync::oneshot::channel(); @@ -3888,7 +3888,7 @@ impl LxmdRunner { /// True when the source destination resolves to a blackholed identity. /// Unknown identities are never dropped, mirroring Python's recall-gated - /// check (LXMessage.py:804 only runs with a recalled source identity). + /// check (LXMessage.py only runs with a recalled source identity). fn source_blackholed(&self, source_hash: &[u8; 16]) -> bool { match recall_identity_hash(&self.known_identities, source_hash) { Some(identity_hash) => self.blackholed_identities.contains(&identity_hash), @@ -4135,7 +4135,7 @@ impl LxmdRunner { .map(|interface| interface.bitrate) .min() { - // Transport keeps the last lowest bitrate when none qualifies (Transport.py:708). + // Transport keeps the last lowest bitrate when none qualifies (Transport.py). self.medium.lowest_interface_bitrate = Some(lowest); } self.medium.medium_path_timeout = self @@ -4653,7 +4653,7 @@ impl LxmdRunner { "learned propagation-node stamp cost from announce" ); } - // Python triggers on pn_announce_data_is_valid alone (Handlers.py:43-53). + // Python triggers on pn_announce_data_is_valid alone (Handlers.py). if event.name_hash == propagation_name_hash && let Some(data) = event.app_data.as_deref() { @@ -4702,7 +4702,7 @@ impl LxmdRunner { len = plaintext.len(), "received decrypted packet via link" ); - // A link packet carries its Link ID as the ratchet ID (Link.py:1039@1.6.0). + // A link packet carries its Link ID as the ratchet ID (Link.py). self.handle_link_delivered_data_on(&plaintext, Some(link_id)); } @@ -4860,7 +4860,7 @@ impl LxmdRunner { len = completion.data.len(), "resource transfer completed on link" ); - // A resource delivery records its Link ID as the ratchet ID (LXMRouter.py:2325-2327). + // A resource delivery records its Link ID as the ratchet ID (LXMRouter.py). self.handle_link_delivered_data_on(&completion.data, Some(completion.link_id)); } _ => {} @@ -5519,7 +5519,7 @@ impl LxmdRunner { } /// `LXMRouter.delivery_packet` reads the packet's RSSI, SNR and Q from - /// Reticulum's per-packet caches (LXMRouter.py:2277-2283@1.3.0). + /// Reticulum's per-packet caches (LXMRouter.py). async fn inbound_packet_phy(&self, raw: &[u8]) -> Option { let (header, _) = rns_wire::header::PacketHeader::unpack(raw).ok()?; let packet_hash = rns_wire::hash::packet_hash(raw, header.flags.header_type); @@ -5574,7 +5574,7 @@ impl LxmdRunner { }; // Python proves every delivery packet before unpacking or gating it - // (LXMRouter.py:2262-2263). + // (LXMRouter.py). if let Some(proof_raw) = self.create_delivery_proof(raw) { let trunc = rns_wire::hash::truncated_packet_hash(raw, header.flags.header_type); if !self.queue_runtime_transport( @@ -5611,7 +5611,7 @@ impl LxmdRunner { "inbound LXMF message received" ); - // LXMRouter.delivery_packet passes packet.ratchet_id (LXMRouter.py:2285). + // LXMRouter.delivery_packet passes packet.ratchet_id (LXMRouter.py). self.admit_inbound_message( msg, DeliveryMethod::Opportunistic, @@ -5625,7 +5625,7 @@ impl LxmdRunner { } } - /// Python `lxmf_delivery` gating (LXMRouter.py:2163-2257): blackholed + /// Python `lxmf_delivery` gating (LXMRouter.py): blackholed /// source, ticket learning from a validated signature, stamp, ignored /// source, then delivery. Unknown or invalid signatures are delivered flagged. fn admit_inbound_message( @@ -5726,7 +5726,7 @@ impl LxmdRunner { // Pack synchronously (CPU-bound, no IO) and offload the disk write // to the blocking pool so a slow disk doesn't stall the lxmd runner // task between inbound messages. Atomic tmp+rename write so readers - // never see a partial file (LXMessage.py:696-712). + // never see a partial file (LXMessage.py). mark_received(&mut msg, method); match msg.pack_container() { Ok(packed) => { @@ -5905,7 +5905,7 @@ impl LxmdRunner { }) { Ok(payload) => payload, Err(error) => { - // A raising send() fails the message (LXMRouter.py:3143-3146). + // A raising send() fails the message (LXMRouter.py). tracing::warn!(dest = %dest_hex, %error, "opportunistic LXMF send failed"); self.last_delivery_failure = Some(error.to_string()); self.router.mark_outbound_failed(&msg_hash); @@ -7296,8 +7296,8 @@ mod tests { } /// Python's router retains a destination's announce data once a message - /// to it is delivered (LXMRouter.py:2761), on the shared instance when - /// attached to one (Reticulum.py:1449-1461). + /// to it is delivered (LXMRouter.py), on the shared instance when + /// attached to one (Reticulum.py). #[tokio::test] async fn delivered_destinations_are_retained_through_the_control_plane() { let temp = tempfile::tempdir().unwrap(); @@ -7352,7 +7352,7 @@ mod tests { } /// Python's LXMF recalls identities that Transport validated before the - /// router registered its handlers (Transport.py:2172, Identity.recall). + /// router registered its handlers (Transport.py, Identity.recall). #[tokio::test] async fn identities_validated_before_the_daemon_subscribed_are_learned() { let node = Identity::new(); @@ -8614,7 +8614,7 @@ mod tests { } } - /// Blackhole gating mirrors LXMessage.py:804: only a recallable source + /// Blackhole gating mirrors LXMessage.py: only a recallable source /// identity can be matched against the blackhole table; unknown sources /// never drop. #[test]