Skip to content

Commit

Permalink
fix(tutorial): import dependencies via meta crate
Browse files Browse the repository at this point in the history
Pull-Request: libp2p#4949.
  • Loading branch information
indirection42 authored Nov 29, 2023
1 parent 0810672 commit dfd66f9
Showing 1 changed file with 25 additions and 29 deletions.
54 changes: 25 additions & 29 deletions libp2p/src/tutorials/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
//! edition = "2021"
//!
//! [dependencies]
//! libp2p = { version = "0.52", features = ["tcp", "dns", "async-std", "noise", "yamux", "websocket", "ping", "macros"] }
//! libp2p = { version = "0.52", features = ["tcp", "tls", "dns", "async-std", "noise", "yamux", "websocket", "ping", "macros"] }
//! futures = "0.3.21"
//! async-std = { version = "1.12.0", features = ["attributes"] }
//! tracing-subscriber = { version = "0.3", features = ["env-filter"] }
Expand Down Expand Up @@ -95,7 +95,6 @@
//! trait.
//!
//! ```rust
//! use libp2p::{identity, PeerId};
//! use std::error::Error;
//! use tracing_subscriber::EnvFilter;
//!
Expand All @@ -106,9 +105,9 @@
//! let mut swarm = libp2p::SwarmBuilder::with_new_identity()
//! .with_async_std()
//! .with_tcp(
//! libp2p_tcp::Config::default(),
//! libp2p_tls::Config::new,
//! libp2p_yamux::Config::default,
//! libp2p::tcp::Config::default(),
//! libp2p::tls::Config::new,
//! libp2p::yamux::Config::default,
//! )?;
//!
//! Ok(())
Expand Down Expand Up @@ -138,8 +137,7 @@
//! With the above in mind, let's extend our example, creating a [`ping::Behaviour`](crate::ping::Behaviour) at the end:
//!
//! ```rust
//! use libp2p::swarm::NetworkBehaviour;
//! use libp2p::{identity, ping, PeerId};
//! use libp2p::ping;
//! use tracing_subscriber::EnvFilter;
//! use std::error::Error;
//!
Expand All @@ -150,9 +148,9 @@
//! let mut swarm = libp2p::SwarmBuilder::with_new_identity()
//! .with_async_std()
//! .with_tcp(
//! libp2p_tcp::Config::default(),
//! libp2p_tls::Config::new,
//! libp2p_yamux::Config::default,
//! libp2p::tcp::Config::default(),
//! libp2p::tls::Config::new,
//! libp2p::yamux::Config::default,
//! )?
//! .with_behaviour(|_| ping::Behaviour::default())?;
//!
Expand All @@ -168,8 +166,7 @@
//! to the [`Transport`] as well as events from the [`Transport`] to the [`NetworkBehaviour`].
//!
//! ```rust
//! use libp2p::swarm::NetworkBehaviour;
//! use libp2p::{identity, ping, PeerId};
//! use libp2p::ping;
//! use std::error::Error;
//! use tracing_subscriber::EnvFilter;
//!
Expand All @@ -180,9 +177,9 @@
//! let mut swarm = libp2p::SwarmBuilder::with_new_identity()
//! .with_async_std()
//! .with_tcp(
//! libp2p_tcp::Config::default(),
//! libp2p_tls::Config::new,
//! libp2p_yamux::Config::default,
//! libp2p::tcp::Config::default(),
//! libp2p::tls::Config::new,
//! libp2p::yamux::Config::default,
//! )?
//! .with_behaviour(|_| ping::Behaviour::default())?
//! .build();
Expand All @@ -202,8 +199,7 @@
//! Thus, without any other behaviour in place, we would not be able to observe the pings.
//!
//! ```rust
//! use libp2p::swarm::NetworkBehaviour;
//! use libp2p::{identity, ping, PeerId};
//! use libp2p::ping;
//! use std::error::Error;
//! use std::time::Duration;
//! use tracing_subscriber::EnvFilter;
Expand All @@ -215,9 +211,9 @@
//! let mut swarm = libp2p::SwarmBuilder::with_new_identity()
//! .with_async_std()
//! .with_tcp(
//! libp2p_tcp::Config::default(),
//! libp2p_tls::Config::new,
//! libp2p_yamux::Config::default,
//! libp2p::tcp::Config::default(),
//! libp2p::tls::Config::new,
//! libp2p::yamux::Config::default,
//! )?
//! .with_behaviour(|_| ping::Behaviour::default())?
//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(30))) // Allows us to observe pings for 30 seconds.
Expand Down Expand Up @@ -254,7 +250,7 @@
//! remote peer.
//!
//! ```rust
//! use libp2p::{identity, ping, Multiaddr, PeerId};
//! use libp2p::{ping, Multiaddr};
//! use std::error::Error;
//! use std::time::Duration;
//! use tracing_subscriber::EnvFilter;
Expand All @@ -266,9 +262,9 @@
//! let mut swarm = libp2p::SwarmBuilder::with_new_identity()
//! .with_async_std()
//! .with_tcp(
//! libp2p_tcp::Config::default(),
//! libp2p_tls::Config::new,
//! libp2p_yamux::Config::default,
//! libp2p::tcp::Config::default(),
//! libp2p::tls::Config::new,
//! libp2p::yamux::Config::default,
//! )?
//! .with_behaviour(|_| ping::Behaviour::default())?
//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(30))) // Allows us to observe pings for 30 seconds.
Expand Down Expand Up @@ -298,8 +294,8 @@
//!
//! ```no_run
//! use futures::prelude::*;
//! use libp2p::swarm::{NetworkBehaviour, SwarmEvent};
//! use libp2p::{identity, ping, Multiaddr, PeerId};
//! use libp2p::swarm::SwarmEvent;
//! use libp2p::{ping, Multiaddr};
//! use std::error::Error;
//! use std::time::Duration;
//! use tracing_subscriber::EnvFilter;
Expand All @@ -311,9 +307,9 @@
//! let mut swarm = libp2p::SwarmBuilder::with_new_identity()
//! .with_async_std()
//! .with_tcp(
//! libp2p_tcp::Config::default(),
//! libp2p_tls::Config::new,
//! libp2p_yamux::Config::default,
//! libp2p::tcp::Config::default(),
//! libp2p::tls::Config::new,
//! libp2p::yamux::Config::default,
//! )?
//! .with_behaviour(|_| ping::Behaviour::default())?
//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(30))) // Allows us to observe pings for 30 seconds.
Expand Down

0 comments on commit dfd66f9

Please sign in to comment.