transport: announce handler events carry the announce's emission time

This commit is contained in:
DeFiDude committed 2026-11-16 15:34:17 -07:00
1 parent 5976f6bcce
commit 71497c858d
7 files changed
+48 -2

No files matched your search

+2
View File
@@ -2,6 +2,8 @@
## Unreleased
- Announce handler events carry `emitted`, the time the announcer stamped into the announce, so an application can tell an older cached announce in a path response from a newer one. `AnnounceHandlerEvent` struct literals need the new field.
## 1.5.0 - 2026-11-13
### Added
+1
View File
@@ -1308,6 +1308,7 @@ pub struct rns_transport::messages::AnnounceHandlerEvent
pub rns_transport::messages::AnnounceHandlerEvent::announce_packet_hash: [u8; 32]
pub rns_transport::messages::AnnounceHandlerEvent::app_data: core::option::Option<alloc::vec::Vec<u8>>
pub rns_transport::messages::AnnounceHandlerEvent::destination_hash: [u8; 16]
pub rns_transport::messages::AnnounceHandlerEvent::emitted: u64
pub rns_transport::messages::AnnounceHandlerEvent::hops: u8
pub rns_transport::messages::AnnounceHandlerEvent::identity_hash: core::option::Option<[u8; 16]>
pub rns_transport::messages::AnnounceHandlerEvent::is_path_response: bool
+2 -2
View File
@@ -51,8 +51,8 @@
"tier": "provisional",
"compatibility": "reviewed-snapshot",
"snapshot": "api/snapshots/rns-transport.txt",
"itemCount": 2160,
"sha256": "18a2a12e0f5ab6de901b7d439708e131e1756db23dafabd117153229067ca882"
"itemCount": 2161,
"sha256": "486f79c541ecec9e815cd082aec536dfd805acb4947498a7efde8c25632f56a2"
},
{
"name": "rns-link",
@@ -1090,6 +1090,7 @@ impl TransportActor {
announce_packet_hash,
is_path_response,
hops: header.hops,
emitted: announce_emitted,
app_data: handler_app_data.clone(),
public_key: announce_public_key,
ratchet: announce_ratchet,
+38
View File
@@ -13006,6 +13006,7 @@ mod tests {
rns_wire::context::PacketContext::PathResponse,
);
let expected_hash = rns_wire::hash::packet_hash(&raw, rns_wire::flags::HeaderType::Header1);
let expected_emitted = announce_emitted_from_raw(&raw).unwrap();
actor.on_inbound(crate::messages::InboundPacket {
raw,
interface_id: 1,
@@ -13024,6 +13025,43 @@ mod tests {
assert_eq!(event.destination_hash, dest_hash);
assert_eq!(event.announce_packet_hash, expected_hash);
assert!(event.is_path_response);
assert_eq!(event.emitted, expected_emitted);
}
#[test]
fn handler_event_carries_the_stamped_emission_time() {
let (mut actor, _tx) = TransportActor::new();
let (entry, _rx) = make_test_interface("test_iface");
actor.interfaces.insert(1, entry);
let (htx, mut hrx) = mpsc::channel(8);
actor.announce_handlers.push(AnnounceHandlerRegistration {
id: crate::messages::AnnounceHandlerId(0),
ownership: AnnounceHandlerOwnership::Subscription,
aspect_filter: None,
receive_path_responses: false,
tx: htx,
dropped_events: Arc::new(AtomicU64::new(0)),
paused: Arc::new(AtomicBool::new(false)),
});
let emitted = 1_700_000_000;
let identity = rns_identity::identity::Identity::new();
let (raw, _) = make_announce_for_with_random_blob(
&identity,
"test.emitted",
1,
random_blob(0x33, emitted),
);
actor.on_inbound(crate::messages::InboundPacket {
raw,
interface_id: 1,
rssi: None,
snr: None,
q: None,
});
assert_eq!(hrx.try_recv().unwrap().emitted, emitted);
}
#[test]
@@ -845,6 +845,7 @@ mod tests {
announce_packet_hash: [0x22; 32],
is_path_response: false,
hops: 3,
emitted: 0,
app_data: Some(app_data),
public_key: None,
ratchet: None,
@@ -921,6 +922,7 @@ mod tests {
announce_packet_hash: [0; 32],
is_path_response: false,
hops: 0,
emitted: 0,
app_data: None,
public_key: None,
ratchet: None,
+2
View File
@@ -629,6 +629,8 @@ pub struct AnnounceHandlerEvent {
pub announce_packet_hash: [u8; 32],
pub is_path_response: bool,
pub hops: u8,
/// Unix seconds the announcer stamped into the random hash (Python `Transport.announce_emitted`).
pub emitted: u64,
pub app_data: Option<Vec<u8>>,
/// X25519 || Ed25519 public key from the announce payload.
pub public_key: Option<[u8; 64]>,