From d7e3d9f8310aa40903f43272fbb30f37a1f68c2b Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 9 Nov 2026 05:20:44 +0000 Subject: dashboard: the transport each message went by, in the console The console said with whom a message went, not how: the message log was noted above the identity layer (`CountingTransport`), where a message is to or from a node, and the address it went to (the paths layer picks one, `Paths::send_first`) or came from is gone. Only the paths layer's own PINGs and PONGs, logged under their addresses, had one. Now the identity layer notes the node's messages (`MessageLog::set_addressed`), with the address each went to (`IdentityTransport::send_proven` returns it) or came from; `CountingTransport` leaves them to it, and still notes them where there is no identity layer (tests). A console line ends with the transport (the address's scheme, in its colour on the map, the address in the tooltip), and the figures box shows the address. A subscribed node's messages carry theirs too, and the map runs every message along its transport's line, not only the PINGs and PONGs. --- src/transport/traffic.rs | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'src/transport/traffic.rs') diff --git a/src/transport/traffic.rs b/src/transport/traffic.rs index 948e5d5..bac0da7 100644 --- a/src/transport/traffic.rs +++ b/src/transport/traffic.rs @@ -150,12 +150,16 @@ const LOGGED: usize = 1000; const LOGGED_TEXT: usize = 8 * 1024; /// The node's messages one by one, for the dashboard's console (`api::dashboard`): -/// kept only while it looks (`watch`), the latest `LOGGED`. Those this layer sees: the -/// node's own, not the paths layer's PINGs and PONGs nor the identity layer's WHO and -/// ME (counted under their addresses, `ByKind`), but the PINGs and PONGs the node is -/// handed. +/// kept only while it looks (`watch`), the latest `LOGGED`. The node's own, each with +/// the address it went to or came from where the identity layer notes them (`addressed`, +/// `transport::identity`), else as `CountingTransport` sees them; and the paths layer's +/// PINGs and PONGs, under their addresses; not the identity layer's WHO and ME (counted +/// under their addresses, `ByKind`). #[derive(Debug, Default)] pub(crate) struct MessageLog { + /// The identity layer notes the node's messages, with their addresses + /// (`set_addressed`): `CountingTransport`, above it, leaves them to it. + addressed: std::sync::atomic::AtomicBool, /// How many look (`watch`). watching: AtomicUsize, /// Told of each message logged, for those sending them on as they come (`logged`). @@ -192,9 +196,9 @@ pub(crate) struct Logged { /// exchange. #[serde(skip_serializing_if = "Option::is_none")] pub(crate) related: Option, - /// The address it went to or came from, where the paths layer logged it under that - /// (its own PINGs and PONGs) and the node there is known: `peer` is the node then - /// (`api::dashboard`). + /// The address it went to or came from: of a node's message, where the identity + /// layer noted it; of the paths layer's PINGs and PONGs, logged under the address, + /// where the node there is known (`peer` is the node then, `api::dashboard`). #[serde(skip_serializing_if = "Option::is_none")] pub(crate) address: Option, } @@ -254,10 +258,21 @@ impl MessageLog { self.inner.lock_or_recover().next } + /// The identity layer notes the node's messages from now on, with their addresses. + pub(crate) fn set_addressed(&self) { + self.addressed.store(true, Ordering::Relaxed); + } + + /// Whether the identity layer notes the node's messages (`set_addressed`). + pub(crate) fn addressed(&self) -> bool { + self.addressed.load(Ordering::Relaxed) + } + pub(crate) fn note( &self, way: &'static str, peer: &str, + address: Option<&str>, message: &ParsedMessage, bytes: usize, ) { @@ -290,7 +305,7 @@ impl MessageLog { bytes, text, related: related(peer, message), - address: None, + address: address.map(str::to_owned), }); if inner.entries.len() > LOGGED { inner.entries.pop_front(); @@ -523,11 +538,13 @@ impl Transport for CountingTransport { self.traffic .refused(&message.peer, message.kind, message.payload_len); } - if let Some(parsed) = &message.message { + if let Some(parsed) = &message.message + && !self.traffic.log.addressed() + { let way = if result.is_ok() { "sent" } else { "refused" }; self.traffic .log - .note(way, &message.peer, parsed, message.payload_len); + .note(way, &message.peer, None, parsed, message.payload_len); } result } @@ -537,7 +554,11 @@ impl Transport for CountingTransport { self.inner .start_consumer(Box::new(move |sender, message, payload_len| { traffic.received(&sender, message.kind(), payload_len); - traffic.log.note("received", &sender, &message, payload_len); + if !traffic.log.addressed() { + traffic + .log + .note("received", &sender, None, &message, payload_len); + } handler(sender, message, payload_len) })) .await -- cgit v1.3.1