core, lxmd: make inbound link delivery lossless

This commit is contained in:
DeFiDude committed 2026-07-27 00:07:19 -06:00
1 parent a1c3a29603
commit c0bd1ef82f
2 files changed
+12 -9

No files matched your search

+7 -5
View File
@@ -447,7 +447,9 @@ pub struct LinkDeliveryManager {
backchannel_links: HashMap<[u8; 16], [u8; 16]>,
pending: HashMap<[u8; 16], PendingDelivery>,
backchannel_tx: Option<mpsc::Sender<BackchannelSendCommand>>,
inbound_packet_tx: Option<mpsc::Sender<(Vec<u8>, [u8; 16])>>,
/// Unbounded: inbound link data is proved to the peer on receipt, so
/// local delivery must not drop.
inbound_packet_tx: Option<mpsc::UnboundedSender<(Vec<u8>, [u8; 16])>>,
pending_backchannel_starts: Vec<PendingBackchannelStart>,
pending_backchannel_deliveries: HashMap<BackchannelProofKey, PendingBackchannelDelivery>,
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>, [u8; 16])>) {
pub fn set_inbound_packet_sender(&mut self, tx: mpsc::UnboundedSender<(Vec<u8>, [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);
+5 -4
View File
@@ -747,7 +747,7 @@ struct LxmdRunner {
prop_link_command_tx: Option<mpsc::Sender<rns_runtime::link_manager::LinkManagerCommand>>,
transport_tx: mpsc::Sender<TransportMessage>,
/// Plaintext application data decoded by the LinkManager.
link_packet_rx: mpsc::Receiver<(Vec<u8>, [u8; 16])>,
link_packet_rx: mpsc::UnboundedReceiver<(Vec<u8>, [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<LinkManagerAccountingEvent>,
@@ -755,7 +755,7 @@ struct LxmdRunner {
/// consumed from `delivery_accounting_rx` instead.
delivery_resource_event_rx: mpsc::Receiver<LinkResourceEvent>,
/// Plaintext propagation-wrapper packets decoded by the propagation LinkManager.
prop_link_packet_rx: mpsc::Receiver<(Vec<u8>, [u8; 16])>,
prop_link_packet_rx: mpsc::UnboundedReceiver<(Vec<u8>, [u8; 16])>,
/// Ordered, lossless lifecycle and completion stream from the propagation LinkManager.
prop_accounting_rx:
mpsc::UnboundedReceiver<rns_runtime::link_manager::LinkManagerAccountingEvent>,
@@ -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>, [u8; 16])>(256);
let (link_packet_tx, link_packet_rx) = mpsc::unbounded_channel::<(Vec<u8>, [u8; 16])>();
let (delivery_accounting_tx, delivery_accounting_rx) =
mpsc::unbounded_channel::<LinkManagerAccountingEvent>();
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::<InboundResourceCancelRequest>(64);
router.set_inbound_resource_cancel_sender(inbound_resource_cancel_tx);
let (prop_link_packet_tx, prop_link_packet_rx) = mpsc::channel::<(Vec<u8>, [u8; 16])>(256);
let (prop_link_packet_tx, prop_link_packet_rx) =
mpsc::unbounded_channel::<(Vec<u8>, [u8; 16])>();
let (prop_accounting_tx, prop_accounting_rx) =
mpsc::unbounded_channel::<rns_runtime::link_manager::LinkManagerAccountingEvent>();
let (prop_validation_tx, prop_validation_rx) =