From 6a4e3af78a7b75486c699dcf3205ee07a14114ea Mon Sep 17 00:00:00 2001 From: DeFiDude <59237470+DeFiDude@users.noreply.github.com> Date: Wed, 20 May 2026 12:02:57 -0600 Subject: [PATCH] transport: mark path response announce entries --- crates/rns-runtime/src/probe.rs | 2 ++ crates/rns-transport/src/actor/rpc.rs | 27 ++++++++++++++++++--------- crates/rns-transport/src/messages.rs | 3 +++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/crates/rns-runtime/src/probe.rs b/crates/rns-runtime/src/probe.rs index be601d6..59356de 100644 --- a/crates/rns-runtime/src/probe.rs +++ b/crates/rns-runtime/src/probe.rs @@ -456,6 +456,7 @@ mod tests { public_key: Some([0x11; 64]), ratchet: None, name_hash: [0; 10], + is_path_response: false, retained: false, }, AnnounceRpcEntry { @@ -466,6 +467,7 @@ mod tests { public_key: Some([0x22; 64]), ratchet: None, name_hash: [0; 10], + is_path_response: false, retained: false, }, ]; diff --git a/crates/rns-transport/src/actor/rpc.rs b/crates/rns-transport/src/actor/rpc.rs index 014ba04..82fd85a 100644 --- a/crates/rns-transport/src/actor/rpc.rs +++ b/crates/rns-transport/src/actor/rpc.rs @@ -129,15 +129,24 @@ impl TransportActor { let mut entries: Vec = self .recent_announces .values() - .map(|a| AnnounceRpcEntry { - dest_hash: a.dest_hash, - hops: a.hops, - app_data: a.app_data.clone(), - timestamp: a.timestamp, - public_key: a.public_key, - ratchet: a.ratchet, - name_hash: a.name_hash, - retained: a.retained, + .map(|a| { + let is_path_response = + rns_wire::header::PacketHeader::unpack(&a.raw_packet) + .ok() + .is_some_and(|(header, _)| { + header.context == rns_wire::context::PacketContext::PathResponse + }); + AnnounceRpcEntry { + dest_hash: a.dest_hash, + hops: a.hops, + app_data: a.app_data.clone(), + timestamp: a.timestamp, + public_key: a.public_key, + ratchet: a.ratchet, + name_hash: a.name_hash, + is_path_response, + retained: a.retained, + } }) .collect(); // HashMap iteration order is unspecified; sort newest-first diff --git a/crates/rns-transport/src/messages.rs b/crates/rns-transport/src/messages.rs index fd3b88a..f319519 100644 --- a/crates/rns-transport/src/messages.rs +++ b/crates/rns-transport/src/messages.rs @@ -598,6 +598,9 @@ pub struct AnnounceRpcEntry { pub ratchet: Option<[u8; 32]>, /// `SHA-256(app_name)[:10]` for the announced aspect. pub name_hash: [u8; 10], + /// True when the cached announce arrived as a path response instead of a + /// fresh network announce. + pub is_path_response: bool, /// Pinned via `RetainDestination`; the maintenance sweep skips the /// entry regardless of age while this is `true`. pub retained: bool,