From b22934be64a50c68624c01b917d09086701e6d97 Mon Sep 17 00:00:00 2001 From: folex <0xdxdy@gmail.com> Date: Sat, 28 Mar 2020 20:24:55 +0300 Subject: [PATCH] hide public key from Debug --- protocols/kad/Cargo.toml | 1 + protocols/kad/src/behaviour.rs | 5 ++++- protocols/kad/src/protocol.rs | 7 +++++-- protocols/kad/src/record.rs | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index e689d8e0..3e9754e3 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -29,6 +29,7 @@ uint = "0.8" unsigned-varint = { version = "0.3", features = ["futures-codec"] } void = "1.0" bs58 = "0.3.0" +derivative = "2.0.2" trust-graph = { git = "ssh://git@github.com/fluencelabs/arqada.git", branch = "libp2p_migration" } diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 87658a0f..2d98144f 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -49,6 +49,7 @@ use std::task::{Context, Poll}; use wasm_timer::Instant; use libp2p_core::identity::ed25519::{Keypair, PublicKey}; use trust_graph::TrustGraph; +use derivative::Derivative; /// Network behaviour that handles Kademlia. pub struct Kademlia { @@ -1539,7 +1540,8 @@ impl Quorum { /// The events produced by the `Kademlia` behaviour. /// /// See [`NetworkBehaviour::poll`]. -#[derive(Debug)] +#[derive(Derivative)] +#[derivative(Debug)] pub enum KademliaEvent { /// The result of [`Kademlia::bootstrap`]. BootstrapResult(BootstrapResult), @@ -1575,6 +1577,7 @@ pub enum KademliaEvent { /// towards the local peer. ty: KadConnectionType, /// PublicKey of the discovered peer + #[derivative(Debug="ignore")] public_key: PublicKey }, diff --git a/protocols/kad/src/protocol.rs b/protocols/kad/src/protocol.rs index 0639544f..f46d5183 100644 --- a/protocols/kad/src/protocol.rs +++ b/protocols/kad/src/protocol.rs @@ -35,7 +35,8 @@ use futures::prelude::*; use futures_codec::Framed; use prost::Message; use unsigned_varint::codec; -use wasm_timer::Instant; +use derivative::Derivative; +use std::time::Instant; use libp2p_core::{Multiaddr, PeerId}; use libp2p_core::identity::ed25519::PublicKey; @@ -85,8 +86,10 @@ impl Into for KadConnectionType { } /// Information about a peer, as known by the sender. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Derivative)] +#[derivative(Debug, Clone, PartialEq, Eq)] pub struct KadPeer { + #[derivative(Debug="ignore")] pub public_key: PublicKey, /// Identifier of the peer. pub node_id: PeerId, diff --git a/protocols/kad/src/record.rs b/protocols/kad/src/record.rs index c070d88b..e371d58e 100644 --- a/protocols/kad/src/record.rs +++ b/protocols/kad/src/record.rs @@ -112,7 +112,7 @@ pub struct ProviderRecord { pub provider: PeerId, /// The expiration time as measured by a local, monotonic clock. pub expires: Option, - // pub weight: u32 + // pub weight: u32 // TODO: weight } impl Hash for ProviderRecord {