Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Dec 13, 2024
1 parent 1082f40 commit 32a48da
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions iroh/src/magicsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use std::{
use anyhow::{anyhow, Context as _, Result};
use bytes::Bytes;
use concurrent_queue::ConcurrentQueue;
use data_encoding::HEXLOWER;
use futures_lite::{FutureExt, StreamExt};
use futures_util::{stream::BoxStream, task::AtomicWaker};
use iroh_base::{NodeAddr, NodeId, PublicKey, RelayUrl, SecretKey, SharedSecret};
Expand Down Expand Up @@ -1070,20 +1071,20 @@ impl MagicSock {
let handled = self.node_map.handle_ping(sender, addr.clone(), dm.tx_id);
match handled.role {
PingRole::Duplicate => {
debug!(%src, tx = %hex_encode(dm.tx_id), "received ping: path already confirmed, skip");
debug!(%src, tx = %HEXLOWER.encode(&dm.tx_id), "received ping: path already confirmed, skip");
return;
}
PingRole::LikelyHeartbeat => {}
PingRole::NewPath => {
debug!(%src, tx = %hex_encode(dm.tx_id), "received ping: new path");
debug!(%src, tx = %HEXLOWER.encode(&dm.tx_id), "received ping: new path");
}
PingRole::Activate => {
debug!(%src, tx = %hex_encode(dm.tx_id), "received ping: path active");
debug!(%src, tx = %HEXLOWER.encode(&dm.tx_id), "received ping: path active");
}
}

// Send a pong.
debug!(tx = %hex_encode(dm.tx_id), %addr, dstkey = %sender.fmt_short(),
debug!(tx = %HEXLOWER.encode(&dm.tx_id), %addr, dstkey = %sender.fmt_short(),
"sending pong");
let pong = disco::Message::Pong(disco::Pong {
tx_id: dm.tx_id,
Expand Down Expand Up @@ -1137,11 +1138,11 @@ impl MagicSock {
};
if sent {
let msg_sender = self.actor_sender.clone();
trace!(%dst, tx = %hex_encode(tx_id), ?purpose, "ping sent (queued)");
trace!(%dst, tx = %HEXLOWER.encode(&tx_id), ?purpose, "ping sent (queued)");
self.node_map
.notify_ping_sent(id, dst, tx_id, purpose, msg_sender);
} else {
warn!(dst = ?dst, tx = %hex_encode(tx_id), ?purpose, "failed to send ping: queues full");
warn!(dst = ?dst, tx = %HEXLOWER.encode(&tx_id), ?purpose, "failed to send ping: queues full");
}
}

Expand Down Expand Up @@ -1321,7 +1322,7 @@ impl MagicSock {
node_key: self.public_key(),
});
self.try_send_disco_message(dst.clone(), dst_node, msg)?;
debug!(%dst, tx = %hex_encode(tx_id), ?purpose, "ping sent (polled)");
debug!(%dst, tx = %HEXLOWER.encode(&tx_id), ?purpose, "ping sent (polled)");
let msg_sender = self.actor_sender.clone();
self.node_map
.notify_ping_sent(id, dst.clone(), tx_id, purpose, msg_sender);
Expand Down Expand Up @@ -2835,10 +2836,6 @@ impl NetInfo {
}
}

fn hex_encode(b: impl AsRef<[u8]>) -> String {
data_encoding::HEXLOWER.encode(b.as_ref())
}

#[cfg(test)]
mod tests {
use anyhow::Context;
Expand Down Expand Up @@ -3063,8 +3060,8 @@ mod tests {
val,
msg,
"[sender] expected {}, got {}",
hex_encode(msg),
hex_encode(&val)
HEXLOWER.encode(msg),
HEXLOWER.encode(&val)
);

let stats = conn.stats();
Expand Down Expand Up @@ -3469,8 +3466,8 @@ mod tests {
anyhow::ensure!(
val == $msg,
"expected {}, got {}",
hex_encode($msg),
hex_encode(val)
HEXLOWER.encode(&$msg[..]),
HEXLOWER.encode(&val)
);
};
}
Expand Down Expand Up @@ -3622,8 +3619,8 @@ mod tests {
anyhow::ensure!(
val == $msg,
"expected {}, got {}",
hex_encode($msg),
hex_encode(val)
HEXLOWER.encode(&$msg[..]),
HEXLOWER.encode(&val)
);
};
}
Expand Down

0 comments on commit 32a48da

Please sign in to comment.