Refactor multiaddr crate. (#498)

Refactor multiaddr crate.

- Remove `AddrComponent`. Instead `Protocol` directly contains its
associated data.

- Various smaller changes around conversions to Multiaddr from other
types, e.g. socket addresses.

- Expand tests to include property tests which test encoding/decoding
identity.
This commit is contained in:
Toralf Wittner
2018-09-20 19:51:00 +02:00
committed by GitHub
parent 1969bde4fe
commit 84b089cacc
18 changed files with 669 additions and 748 deletions

View File

@ -46,7 +46,7 @@ use futures::sync::mpsc;
use futures::{future, Future, Poll, Sink, Stream};
use libp2p_core::{ConnectionUpgrade, Endpoint, PeerId};
use log::Level;
use multiaddr::{AddrComponent, Multiaddr};
use multiaddr::{Protocol, Multiaddr};
use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard};
use protobuf::Message as ProtobufMessage;
use smallvec::SmallVec;
@ -602,7 +602,7 @@ fn handle_packet_received(
}
};
let from: Multiaddr = AddrComponent::P2P(peer_id.into()).into();
let from: Multiaddr = Protocol::P2p(peer_id.into()).into();
let topics = publish
.take_topicIDs()