summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/swarm/peer/inbound.rs2
-rw-r--r--src/transport/mycelium/mod.rs39
-rw-r--r--src/transport/paths.rs17
3 files changed, 28 insertions, 30 deletions
diff --git a/src/swarm/peer/inbound.rs b/src/swarm/peer/inbound.rs
index 2e89739..6a149a2 100644
--- a/src/swarm/peer/inbound.rs
+++ b/src/swarm/peer/inbound.rs
@@ -81,8 +81,6 @@ pub(crate) async fn handle_message(
};
let same_epoch = observe_peer_epoch(state, &peer, epoch, epoch_seq, run).await;
- //debug!(from = %peer, message = ?message, "Received message");
-
match message {
transport::ParsedMessage::Hello(hello) => {
// A HELLO means the peer is (re)starting its handshake with us, e.g. after a
diff --git a/src/transport/mycelium/mod.rs b/src/transport/mycelium/mod.rs
index 5e8dc05..d33e323 100644
--- a/src/transport/mycelium/mod.rs
+++ b/src/transport/mycelium/mod.rs
@@ -246,31 +246,17 @@ impl Transport for MyceliumTransport {
.into());
}
- // Mycelium's message ID, for GET /api/v1/messages/status/{id} when chasing
- // a message that never arrived.
- if tracing::enabled!(tracing::Level::DEBUG) {
- let Ok(body) = response
+ // Mycelium's message ID, for GET /api/v1/messages/status/{id} when chasing a
+ // message that never arrived. The message itself is logged above, in the paths
+ // layer (`transport::paths`).
+ if tracing::enabled!(tracing::Level::TRACE) {
+ let id = response
.bytes()
.await
- .map_err(anyhow::Error::from)
- .and_then(|bytes| Ok(serde_json::from_slice::<serde_json::Value>(&bytes)?))
- else {
- tracing::debug!(to = %Addressed(SCHEME, &message.peer), "Sent message (couldn't decode response from Mycelium REST API)");
- return Ok(());
- };
- let Ok(outbound) = serde_json::from_slice::<OutboundMessage>(&message.body) else {
- tracing::debug!(to = %Addressed(SCHEME, &message.peer), body_len = %message.body.len(), "Sent message (couldn't parse outbound message)");
- return Ok(());
- };
- let Ok(parsed) = decode_payload(&outbound.topic, &outbound.payload) else {
- tracing::debug!(to = %Addressed(SCHEME, &message.peer), message = ?outbound, "Sent message (couldn't decode outbound message)");
- return Ok(());
- };
- let Some(id) = body.get("id").and_then(|id| id.as_str()) else {
- tracing::debug!(to = %Addressed(SCHEME, &message.peer), message = ?parsed, "Sent message (couldn't read id from Mycelium REST API response)");
- return Ok(());
- };
- tracing::debug!(to = %Addressed(SCHEME, &message.peer), message = ?parsed, id = %id, "Sent message");
+ .ok()
+ .and_then(|bytes| serde_json::from_slice::<serde_json::Value>(&bytes).ok())
+ .and_then(|body| body.get("id")?.as_str().map(str::to_owned));
+ tracing::trace!(to = %Addressed(SCHEME, &message.peer), id = ?id, "Mycelium took the message");
}
Ok(())
}
@@ -300,12 +286,11 @@ impl Transport for MyceliumTransport {
while let Some(inbound_message) = rx.recv().await {
match parse_message(&inbound_message) {
Ok((sender, parsed)) => {
- tracing::debug!(
+ // The message itself is logged above, in the paths layer.
+ tracing::trace!(
from = %Addressed(SCHEME, &inbound_message.src_pk),
- message = ?parsed,
id = %inbound_message.id,
- //payload_bytes = raw_bytes.len(),
- "Received message"
+ "Mycelium delivered a message"
);
let payload_len = base64_decoded_len(&inbound_message.payload);
if is_probe(&parsed) {
diff --git a/src/transport/paths.rs b/src/transport/paths.rs
index 3baa092..1a01718 100644
--- a/src/transport/paths.rs
+++ b/src/transport/paths.rs
@@ -30,6 +30,11 @@
//! alive. The node's keepalive is a PING too (`swarm::peer::keepalive`), which paths
//! sends like any message, and notes as the probe of the path it went over.
//!
+//! Every message on every transport passes here, so this is where messages are logged
+//! (debug): `Sent message` once a transport took one, `Received message` as one
+//! arrives, each with its address and what it says. Failed sends are logged by those who
+//! sent them, with what they do about it.
+//!
//! The debug firewall (`transport::firewall`) works here, below everything else, through
//! a `Gate`: messages from an address it blocks are dropped as they arrive, and sends to
//! one are dropped silently, as by a lossy network.
@@ -665,7 +670,16 @@ impl Paths {
let mut inner = message.clone();
inner.peer = target.clone();
inner.address = target;
- link.inner.send_encoded(&inner).await
+ link.inner.send_encoded(&inner).await?;
+ match &message.message {
+ Some(parsed) => {
+ debug!(to = %message.address, bytes = message.payload_len, message = ?parsed, "Sent message");
+ }
+ None => {
+ debug!(to = %message.address, bytes = message.payload_len, kind = ?message.kind, "Sent message");
+ }
+ }
+ Ok(())
}
/// How the transport of `address` is connected there (`Transport::connection`).
@@ -762,6 +776,7 @@ impl Paths {
tracing::trace!(from = %address, "Firewall dropped inbound message");
return Ok(());
}
+ debug!(from = %address, bytes = payload_len, message = ?message, "Received message");
match message {
ParsedMessage::Ping(nonce) => {
let paths = Arc::clone(&self);