Fix doctests of libp2p-swarm

This commit is contained in:
Pierre Krieger 2017-12-05 10:17:24 +01:00
parent 5e6a6a9202
commit 3edbff0172
2 changed files with 6 additions and 6 deletions

View File

@ -52,7 +52,7 @@ extern crate tokio_core;
use libp2p_swarm::Transport;
let tokio_core = tokio_core::reactor::Core::new().unwrap();
let tcp_transport = libp2p_tcp_transport::Tcp::new(tokio_core.handle()).unwrap();
let tcp_transport = libp2p_tcp_transport::TcpConfig::new(tokio_core.handle());
let upgraded = tcp_transport.with_upgrade(libp2p_swarm::PlainText);
// upgraded.dial(...) // automatically applies the plain text protocol on the socket
@ -83,8 +83,8 @@ use libp2p_swarm::Transport;
let mut core = tokio_core::reactor::Core::new().unwrap();
let ping_finished_future = libp2p_tcp_transport::Tcp::new(core.handle()).unwrap()
// We have a `Tcp` struct that implements `Transport`, and apply a `Ping` upgrade on it.
let ping_finished_future = libp2p_tcp_transport::TcpConfig::new(core.handle())
// We have a `TcpConfig` struct that implements `Transport`, and apply a `Ping` upgrade on it.
.with_upgrade(Ping)
// TODO: right now the only available protocol is ping, but we want to replace it with
// something that is more simple to use

View File

@ -76,7 +76,7 @@
//!
//! # fn main() {
//! let tokio_core = tokio_core::reactor::Core::new().unwrap();
//! let tcp_transport = libp2p_tcp_transport::Tcp::new(tokio_core.handle()).unwrap();
//! let tcp_transport = libp2p_tcp_transport::TcpConfig::new(tokio_core.handle());
//! let upgraded = tcp_transport.with_upgrade(libp2p_swarm::PlainText);
//!
//! // upgraded.dial(...) // automatically applies the plain text protocol on the socket
@ -109,8 +109,8 @@
//! # fn main() {
//! let mut core = tokio_core::reactor::Core::new().unwrap();
//!
//! let ping_finished_future = libp2p_tcp_transport::Tcp::new(core.handle()).unwrap()
//! // We have a `Tcp` struct that implements `Transport`, and apply a `Ping` upgrade on it.
//! let ping_finished_future = libp2p_tcp_transport::TcpConfig::new(core.handle())
//! // We have a `TcpConfig` struct that implements `Transport`, and apply a `Ping` upgrade on it.
//! .with_upgrade(Ping)
//! // TODO: right now the only available protocol is ping, but we want to replace it with
//! // something that is more simple to use