mirror of
https://github.com/ratspeak/rsReticulum
synced 2026-11-27 13:52:16 +00:00
transport: mark path response announce entries
This commit is contained in:
1 parent
ffe641b3af
commit
6a4e3af78a
3 files changed
+23
-9
No files matched your search
@@ -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,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -129,15 +129,24 @@ impl TransportActor {
|
||||
let mut entries: Vec<AnnounceRpcEntry> = 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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user