Skip to content

Commit

Permalink
refactor: display decoded client type in utp logs (#1371)
Browse files Browse the repository at this point in the history
  • Loading branch information
njgheorghita authored Aug 13, 2024
1 parent d6f0ec2 commit 8c19453
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion portalnet/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ impl Discv5UdpSocket {
}

/// A wrapper around `Enr` that implements `ConnectionPeer`.
#[derive(Clone, Debug)]
#[derive(Clone)]
pub struct UtpEnr(pub Enr);

impl UtpEnr {
Expand All @@ -433,6 +433,16 @@ impl UtpEnr {
}
}

impl std::fmt::Debug for UtpEnr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let peer_client_type = self.client().unwrap_or_else(|| "Unknown".to_string());
f.debug_struct("UtpEnr")
.field("enr", &self.0)
.field("Peer Client Type", &peer_client_type)
.finish()
}
}

// Why are we implementing Hash, PartialEq, Eq for UtpEnr?
// UtpEnr is used as an element of the key for a Connections HashTable in our uTP library.
// Enr's can change and are not stable, so if we initiate a ``connect_with_cid`` we are inserting
Expand Down

0 comments on commit 8c19453

Please sign in to comment.