Change Multiaddr representation to Bytes. (#1041)

* Change `Multiaddr` representation to `Bytes`.

* Mark several `Multiaddr` methods as deprecated.
This commit is contained in:
Toralf Wittner
2019-04-08 10:57:09 +02:00
committed by GitHub
parent 480cf380d7
commit 98b2517403
6 changed files with 52 additions and 44 deletions

View File

@ -103,7 +103,7 @@ impl KadPeer {
let mut addrs = Vec::with_capacity(peer.get_addrs().len());
for addr in peer.take_addrs().into_iter() {
let as_ma = Multiaddr::from_bytes(addr)
let as_ma = Multiaddr::try_from_vec(addr)
.map_err(|err| IoError::new(IoErrorKind::InvalidData, err))?;
addrs.push(as_ma);
}
@ -124,7 +124,7 @@ impl Into<protobuf_structs::dht::Message_Peer> for KadPeer {
let mut out = protobuf_structs::dht::Message_Peer::new();
out.set_id(self.node_id.into_bytes());
for addr in self.multiaddrs {
out.mut_addrs().push(addr.into_bytes());
out.mut_addrs().push(addr.to_vec());
}
out.set_connection(self.connection_ty.into());
out