This commit is contained in:
folex 2020-03-19 15:12:48 +03:00
parent 84fc48f1ac
commit 87b8e23553
2 changed files with 25 additions and 3 deletions

View File

@ -28,6 +28,7 @@ wasm-timer = "0.2"
uint = "0.8"
unsigned-varint = { version = "0.3", features = ["futures-codec"] }
void = "1.0"
bs58 = "0.3.0"
[dev-dependencies]
libp2p-secio = { version = "0.16.0", path = "../secio" }

View File

@ -14,14 +14,13 @@
* limitations under the License.
*/
// TODO: modify src/dht.proto
use crate::Addresses;
use libp2p_core::{Multiaddr};
use libp2p_core::identity::ed25519::PublicKey;
use crate::protocol::KadPeer;
use smallvec::SmallVec;
use std::fmt::Formatter;
use bs58;
#[derive(Clone, PartialEq, Eq)]
pub struct Contact {
@ -68,3 +67,25 @@ impl From<KadPeer> for Contact {
}
}
}
impl std::fmt::Display for Contact {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"Contact({}, addresses: {:?})",
bs58::encode(self.public_key.encode()).into_string(),
self.addresses // TODO: implement better display for addresses
)
}
}
impl std::fmt::Debug for Contact {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"Contact {{ public_key: {}, addresses: {:?} }}",
bs58::encode(self.public_key.encode()).into_string(),
self.addresses // TODO: implement better display for addresses
)
}
}