From c0bd1ef82f9bbc67c57a314b004430906e6dc02c Mon Sep 17 00:00:00 2001 From: DeFiDude <59237470+DeFiDude@users.noreply.github.com> Date: Mon, 27 Jul 2026 00:07:19 -0600 Subject: [PATCH] core, lxmd: make inbound link delivery lossless --- crates/lxmf-core/src/link_delivery.rs | 12 +++++++----- crates/lxmf-tools/src/commands/lxmd.rs | 9 +++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/crates/lxmf-core/src/link_delivery.rs b/crates/lxmf-core/src/link_delivery.rs index d9988d2..778c30a 100644 --- a/crates/lxmf-core/src/link_delivery.rs +++ b/crates/lxmf-core/src/link_delivery.rs @@ -447,7 +447,9 @@ pub struct LinkDeliveryManager { backchannel_links: HashMap<[u8; 16], [u8; 16]>, pending: HashMap<[u8; 16], PendingDelivery>, backchannel_tx: Option>, - inbound_packet_tx: Option, [u8; 16])>>, + /// Unbounded: inbound link data is proved to the peer on receipt, so + /// local delivery must not drop. + inbound_packet_tx: Option, [u8; 16])>>, pending_backchannel_starts: Vec, pending_backchannel_deliveries: HashMap, identity_pub: Option<[u8; 64]>, @@ -492,7 +494,7 @@ impl LinkDeliveryManager { /// backchannels: the outbound Direct manager owns the link_id destination, /// so ordinary link DATA replies route back here rather than to the /// responder-side LinkManager. - pub fn set_inbound_packet_sender(&mut self, tx: mpsc::Sender<(Vec, [u8; 16])>) { + pub fn set_inbound_packet_sender(&mut self, tx: mpsc::UnboundedSender<(Vec, [u8; 16])>) { self.inbound_packet_tx = Some(tx); } @@ -1227,7 +1229,7 @@ impl LinkDeliveryManager { }; if let Some(ref tx) = self.inbound_packet_tx { - let _ = tx.try_send((plaintext, *link_id)); + let _ = tx.send((plaintext, *link_id)); } let packet_hash = rns_wire::hash::packet_hash(raw, header_type); @@ -3745,7 +3747,7 @@ mod tests { #[test] fn test_outbound_direct_link_accepts_backchannel_packet() { let (tx, mut rx) = mpsc::channel(128); - let (inbound_tx, mut inbound_rx) = mpsc::channel(4); + let (inbound_tx, mut inbound_rx) = mpsc::unbounded_channel(); let mut mgr = LinkDeliveryManager::new(tx, None, None); mgr.set_inbound_packet_sender(inbound_tx); @@ -3812,7 +3814,7 @@ mod tests { #[test] fn test_outbound_direct_backchannel_proof_uses_received_header_type() { let (tx, mut rx) = mpsc::channel(128); - let (inbound_tx, mut inbound_rx) = mpsc::channel(4); + let (inbound_tx, mut inbound_rx) = mpsc::unbounded_channel(); let mut mgr = LinkDeliveryManager::new(tx, None, None); mgr.set_inbound_packet_sender(inbound_tx); diff --git a/crates/lxmf-tools/src/commands/lxmd.rs b/crates/lxmf-tools/src/commands/lxmd.rs index 1242dcd..acaa8b9 100644 --- a/crates/lxmf-tools/src/commands/lxmd.rs +++ b/crates/lxmf-tools/src/commands/lxmd.rs @@ -747,7 +747,7 @@ struct LxmdRunner { prop_link_command_tx: Option>, transport_tx: mpsc::Sender, /// Plaintext application data decoded by the LinkManager. - link_packet_rx: mpsc::Receiver<(Vec, [u8; 16])>, + link_packet_rx: mpsc::UnboundedReceiver<(Vec, [u8; 16])>, /// Ordered, lossless ordinary delivery Resource starts/conclusions and /// payload completions used by delivery and the public inbound tracker. delivery_accounting_rx: mpsc::UnboundedReceiver, @@ -755,7 +755,7 @@ struct LxmdRunner { /// consumed from `delivery_accounting_rx` instead. delivery_resource_event_rx: mpsc::Receiver, /// Plaintext propagation-wrapper packets decoded by the propagation LinkManager. - prop_link_packet_rx: mpsc::Receiver<(Vec, [u8; 16])>, + prop_link_packet_rx: mpsc::UnboundedReceiver<(Vec, [u8; 16])>, /// Ordered, lossless lifecycle and completion stream from the propagation LinkManager. prop_accounting_rx: mpsc::UnboundedReceiver, @@ -878,7 +878,7 @@ impl LxmdRunner { // LinkManager handles link handshakes (ECDH), keepalive, identification, // and resource transfers; it forwards plaintext application data here. let (delivery_tx, delivery_rx) = mpsc::channel(256); - let (link_packet_tx, link_packet_rx) = mpsc::channel::<(Vec, [u8; 16])>(256); + let (link_packet_tx, link_packet_rx) = mpsc::unbounded_channel::<(Vec, [u8; 16])>(); let (delivery_accounting_tx, delivery_accounting_rx) = mpsc::unbounded_channel::(); let (delivery_resource_event_tx, delivery_resource_event_rx) = @@ -886,7 +886,8 @@ impl LxmdRunner { let (inbound_resource_cancel_tx, inbound_resource_cancel_rx) = mpsc::channel::(64); router.set_inbound_resource_cancel_sender(inbound_resource_cancel_tx); - let (prop_link_packet_tx, prop_link_packet_rx) = mpsc::channel::<(Vec, [u8; 16])>(256); + let (prop_link_packet_tx, prop_link_packet_rx) = + mpsc::unbounded_channel::<(Vec, [u8; 16])>(); let (prop_accounting_tx, prop_accounting_rx) = mpsc::unbounded_channel::(); let (prop_validation_tx, prop_validation_rx) =