From 3233b8e7edf87c0f3da4135b6b7c5431f418c0db Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Tue, 16 May 2023 21:33:11 +0200 Subject: [PATCH 01/11] swarm remove deprecated items --- swarm/src/behaviour.rs | 25 ------- swarm/src/connection.rs | 9 --- swarm/src/connection/pool.rs | 2 - swarm/src/handler.rs | 3 - swarm/src/lib.rs | 134 +---------------------------------- 5 files changed, 2 insertions(+), 171 deletions(-) diff --git a/swarm/src/behaviour.rs b/swarm/src/behaviour.rs index c5e5b7f25c3..6303e65bc1f 100644 --- a/swarm/src/behaviour.rs +++ b/swarm/src/behaviour.rs @@ -224,37 +224,12 @@ pub trait PollParameters { /// Iterator returned by [`external_addresses`](PollParameters::external_addresses). type ExternalAddressesIter: ExactSizeIterator; - /// Returns the list of protocol the behaviour supports when a remote negotiates a protocol on - /// an inbound substream. - /// - /// The iterator's elements are the ASCII names as reported on the wire. - /// - /// Note that the list is computed once at initialization and never refreshed. - #[deprecated( - note = "Use `libp2p_swarm::SupportedProtocols` in your `ConnectionHandler` instead." - )] - fn supported_protocols(&self) -> Self::SupportedProtocolsIter; - - /// Returns the list of the addresses we're listening on. - #[deprecated( - since = "0.42.0", - note = "Use `libp2p_swarm::ListenAddresses` instead." - )] - fn listened_addresses(&self) -> Self::ListenedAddressesIter; - /// Returns the list of the addresses nodes can use to reach us. #[deprecated( since = "0.42.0", note = "Use `libp2p_swarm::ExternalAddresses` instead." )] fn external_addresses(&self) -> Self::ExternalAddressesIter; - - /// Returns the peer id of the local node. - #[deprecated( - since = "0.42.0", - note = "Pass the node's `PeerId` into the behaviour instead." - )] - fn local_peer_id(&self) -> &PeerId; } /// A command issued from a [`NetworkBehaviour`] for the [`Swarm`]. diff --git a/swarm/src/connection.rs b/swarm/src/connection.rs index 43be1c98e3a..a95022db438 100644 --- a/swarm/src/connection.rs +++ b/swarm/src/connection.rs @@ -66,15 +66,6 @@ static NEXT_CONNECTION_ID: AtomicUsize = AtomicUsize::new(1); pub struct ConnectionId(usize); impl ConnectionId { - /// A "dummy" [`ConnectionId`]. - /// - /// Really, you should not use this, not even for testing but it is here if you need it. - #[deprecated( - since = "0.42.0", - note = "Don't use this, it will be removed at a later stage again." - )] - pub const DUMMY: ConnectionId = ConnectionId(0); - /// Creates an _unchecked_ [`ConnectionId`]. /// /// [`Swarm`](crate::Swarm) enforces that [`ConnectionId`]s are unique and not reused. diff --git a/swarm/src/connection/pool.rs b/swarm/src/connection/pool.rs index 36fa0adf3e9..e9f7504f529 100644 --- a/swarm/src/connection/pool.rs +++ b/swarm/src/connection/pool.rs @@ -406,7 +406,6 @@ where /// Adds a pending outgoing connection to the pool in the form of a `Future` /// that establishes and negotiates the connection. - #[allow(deprecated)] pub(crate) fn add_outgoing( &mut self, dials: Vec< @@ -486,7 +485,6 @@ where ); } - #[allow(deprecated)] pub(crate) fn spawn_connection( &mut self, id: ConnectionId, diff --git a/swarm/src/handler.rs b/swarm/src/handler.rs index edefb7a1cb9..de56de1dfa8 100644 --- a/swarm/src/handler.rs +++ b/swarm/src/handler.rs @@ -611,9 +611,6 @@ impl } } -#[deprecated(note = "Renamed to `StreamUpgradeError`")] -pub type ConnectionHandlerUpgrErr = StreamUpgradeError; - /// Error that can happen on an outbound substream opening attempt. #[derive(Debug)] pub enum StreamUpgradeError { diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index f0f5f07cb97..a3162195cb2 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -132,7 +132,7 @@ use connection::{ PendingConnectionError, PendingInboundConnectionError, PendingOutboundConnectionError, }; use dial_opts::{DialOpts, PeerCondition}; -use futures::{executor::ThreadPoolBuilder, prelude::*, stream::FusedStream}; +use futures::{prelude::*, stream::FusedStream}; use libp2p_core::{ connection::ConnectedPoint, multiaddr, @@ -153,19 +153,11 @@ use std::{ task::{Context, Poll}, }; -/// Substream for which a protocol has been chosen. -/// -/// Implements the [`AsyncRead`](futures::io::AsyncRead) and -/// [`AsyncWrite`](futures::io::AsyncWrite) traits. -#[deprecated(note = "The 'substream' terminology is deprecated. Use 'Stream' instead")] -pub type NegotiatedSubstream = Stream; - /// Event generated by the [`NetworkBehaviour`] that the swarm will report back. type TBehaviourOutEvent = ::ToSwarm; /// [`ConnectionHandler`] of the [`NetworkBehaviour`] for all the protocols the [`NetworkBehaviour`] /// supports. -#[allow(deprecated)] pub type THandler = ::ConnectionHandler; /// Custom event that can be received by the [`ConnectionHandler`] of the @@ -339,121 +331,10 @@ where impl Unpin for Swarm where TBehaviour: NetworkBehaviour {} -#[allow(deprecated)] impl Swarm where TBehaviour: NetworkBehaviour, { - /// Builds a new `Swarm` with a provided executor. - #[deprecated(note = "Use `SwarmBuilder::with_executor` instead.")] - pub fn with_executor( - transport: transport::Boxed<(PeerId, StreamMuxerBox)>, - behaviour: TBehaviour, - local_peer_id: PeerId, - executor: impl Executor + Send + 'static, - ) -> Self { - SwarmBuilder::with_executor(transport, behaviour, local_peer_id, executor).build() - } - - /// Builds a new `Swarm` with a tokio executor. - #[cfg(all( - feature = "tokio", - not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")) - ))] - #[deprecated(note = "Use `SwarmBuilder::with_tokio_executor` instead.")] - pub fn with_tokio_executor( - transport: transport::Boxed<(PeerId, StreamMuxerBox)>, - behaviour: TBehaviour, - local_peer_id: PeerId, - ) -> Self { - Self::with_executor( - transport, - behaviour, - local_peer_id, - crate::executor::TokioExecutor, - ) - } - - /// Builds a new `Swarm` with an async-std executor. - #[cfg(all( - feature = "async-std", - not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")) - ))] - #[deprecated(note = "Use `SwarmBuilder::with_async_std_executor` instead.")] - pub fn with_async_std_executor( - transport: transport::Boxed<(PeerId, StreamMuxerBox)>, - behaviour: TBehaviour, - local_peer_id: PeerId, - ) -> Self { - Self::with_executor( - transport, - behaviour, - local_peer_id, - crate::executor::AsyncStdExecutor, - ) - } - - /// Builds a new `Swarm` with a threadpool executor. - #[deprecated( - note = "The `futures::executor::ThreadPool` executor is deprecated. See https://github.com/libp2p/rust-libp2p/issues/3107." - )] - pub fn with_threadpool_executor( - transport: transport::Boxed<(PeerId, StreamMuxerBox)>, - behaviour: TBehaviour, - local_peer_id: PeerId, - ) -> Self { - let builder = match ThreadPoolBuilder::new() - .name_prefix("libp2p-swarm-task-") - .create() - { - Ok(tp) => SwarmBuilder::with_executor(transport, behaviour, local_peer_id, tp), - Err(err) => { - log::warn!("Failed to create executor thread pool: {:?}", err); - SwarmBuilder::without_executor(transport, behaviour, local_peer_id) - } - }; - builder.build() - } - - /// Builds a new `Swarm` with a wasm executor. - /// Background tasks will be executed by the browser on the next micro-tick. - /// - /// Spawning a task is similar too: - /// ```typescript - /// function spawn(task: () => Promise) { - /// task() - /// } - /// ``` - #[cfg(feature = "wasm-bindgen")] - #[deprecated(note = "Use `SwarmBuilder::with_wasm_executor` instead.")] - pub fn with_wasm_executor( - transport: transport::Boxed<(PeerId, StreamMuxerBox)>, - behaviour: TBehaviour, - local_peer_id: PeerId, - ) -> Self { - Self::with_executor( - transport, - behaviour, - local_peer_id, - crate::executor::WasmBindgenExecutor, - ) - } - - /// Builds a new `Swarm` without an executor, instead using the current task. - /// - /// ## ⚠️ Performance warning - /// All connections will be polled on the current task, thus quite bad performance - /// characteristics should be expected. Whenever possible use an executor and - /// [`Swarm::with_executor`]. - #[deprecated(note = "Use `SwarmBuilder::without_executor` instead.")] - pub fn without_executor( - transport: transport::Boxed<(PeerId, StreamMuxerBox)>, - behaviour: TBehaviour, - local_peer_id: PeerId, - ) -> Self { - SwarmBuilder::without_executor(transport, behaviour, local_peer_id).build() - } - /// Returns information about the connections underlying the [`Swarm`]. pub fn network_info(&self) -> NetworkInfo { let num_peers = self.pool.num_peers(); @@ -1401,6 +1282,7 @@ where /// Parameters passed to `poll()`, that the `NetworkBehaviour` has access to. // TODO: #[derive(Debug)] +#[allow(dead_code)] pub struct SwarmPollParameters<'a> { local_peer_id: &'a PeerId, supported_protocols: &'a [Vec], @@ -1413,21 +1295,9 @@ impl<'a> PollParameters for SwarmPollParameters<'a> { type ListenedAddressesIter = std::iter::Cloned>; type ExternalAddressesIter = AddressIntoIter; - fn supported_protocols(&self) -> Self::SupportedProtocolsIter { - self.supported_protocols.iter().cloned() - } - - fn listened_addresses(&self) -> Self::ListenedAddressesIter { - self.listened_addrs.clone().into_iter().cloned() - } - fn external_addresses(&self) -> Self::ExternalAddressesIter { self.external_addrs.clone().into_iter() } - - fn local_peer_id(&self) -> &PeerId { - self.local_peer_id - } } /// A [`SwarmBuilder`] provides an API for configuring and constructing a [`Swarm`]. From 510e5db8a63674fc32699b800c31cf69eaebf91f Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Wed, 17 May 2023 16:33:14 +0200 Subject: [PATCH 02/11] put back supported_protocols --- swarm/src/behaviour.rs | 11 +++++++++++ swarm/src/lib.rs | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/swarm/src/behaviour.rs b/swarm/src/behaviour.rs index 6303e65bc1f..3be3bcc4979 100644 --- a/swarm/src/behaviour.rs +++ b/swarm/src/behaviour.rs @@ -224,6 +224,17 @@ pub trait PollParameters { /// Iterator returned by [`external_addresses`](PollParameters::external_addresses). type ExternalAddressesIter: ExactSizeIterator; + /// Returns the list of protocol the behaviour supports when a remote negotiates a protocol on + /// an inbound substream. + /// + /// The iterator's elements are the ASCII names as reported on the wire. + /// + /// Note that the list is computed once at initialization and never refreshed. + #[deprecated( + note = "Use `libp2p_swarm::SupportedProtocols` in your `ConnectionHandler` instead." + )] + fn supported_protocols(&self) -> Self::SupportedProtocolsIter; + /// Returns the list of the addresses nodes can use to reach us. #[deprecated( since = "0.42.0", diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index a3162195cb2..260643160ce 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1295,6 +1295,10 @@ impl<'a> PollParameters for SwarmPollParameters<'a> { type ListenedAddressesIter = std::iter::Cloned>; type ExternalAddressesIter = AddressIntoIter; + fn supported_protocols(&self) -> Self::SupportedProtocolsIter { + self.supported_protocols.iter().cloned() + } + fn external_addresses(&self) -> Self::ExternalAddressesIter { self.external_addrs.clone().into_iter() } From 5bacaec0825c1435b225d8d2982c070cd841ade2 Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Wed, 17 May 2023 16:36:00 +0200 Subject: [PATCH 03/11] put back ConnectionHandlerUpgrErr --- swarm/src/handler.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/swarm/src/handler.rs b/swarm/src/handler.rs index 7758a2378d7..dcc7ab1c09d 100644 --- a/swarm/src/handler.rs +++ b/swarm/src/handler.rs @@ -619,6 +619,9 @@ impl } } +#[deprecated(note = "Renamed to `StreamUpgradeError`")] +pub type ConnectionHandlerUpgrErr = StreamUpgradeError; + /// Error that can happen on an outbound substream opening attempt. #[derive(Debug)] pub enum StreamUpgradeError { From 5ba97e64a36c5d3efebe7360a5f5afa95c313229 Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Wed, 17 May 2023 16:37:42 +0200 Subject: [PATCH 04/11] put back NegotiatedSubstream --- swarm/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 260643160ce..a75b7b32797 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -153,6 +153,13 @@ use std::{ task::{Context, Poll}, }; +/// Substream for which a protocol has been chosen. +/// +/// Implements the [`AsyncRead`](futures::io::AsyncRead) and +/// [`AsyncWrite`](futures::io::AsyncWrite) traits. +#[deprecated(note = "The 'substream' terminology is deprecated. Use 'Stream' instead")] +pub type NegotiatedSubstream = Stream; + /// Event generated by the [`NetworkBehaviour`] that the swarm will report back. type TBehaviourOutEvent = ::ToSwarm; From 65b5564b20467452e1ee88d49f20c66792da45fb Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Wed, 24 May 2023 11:05:56 +0200 Subject: [PATCH 05/11] update cleaning up --- swarm/src/behaviour.rs | 16 ---------------- swarm/src/lib.rs | 8 -------- 2 files changed, 24 deletions(-) diff --git a/swarm/src/behaviour.rs b/swarm/src/behaviour.rs index a6560190e48..1f26b30336c 100644 --- a/swarm/src/behaviour.rs +++ b/swarm/src/behaviour.rs @@ -232,20 +232,6 @@ pub trait PollParameters { note = "Use `libp2p_swarm::SupportedProtocols` in your `ConnectionHandler` instead." )] fn supported_protocols(&self) -> Self::SupportedProtocolsIter; - - /// Returns the list of the addresses we're listening on. - #[deprecated( - since = "0.42.0", - note = "Use `libp2p_swarm::ListenAddresses` instead." - )] - fn listened_addresses(&self) -> Self::ListenedAddressesIter; - - /// Returns the peer id of the local node. - #[deprecated( - since = "0.42.0", - note = "Pass the node's `PeerId` into the behaviour instead." - )] - fn local_peer_id(&self) -> &PeerId; } /// A command issued from a [`NetworkBehaviour`] for the [`Swarm`]. @@ -413,7 +399,6 @@ pub enum CloseConnection { /// Enumeration with the list of the possible events /// to pass to [`on_swarm_event`](NetworkBehaviour::on_swarm_event). -#[allow(deprecated)] pub enum FromSwarm<'a, Handler> { /// Informs the behaviour about a newly established connection to a peer. ConnectionEstablished(ConnectionEstablished<'a>), @@ -470,7 +455,6 @@ pub struct ConnectionEstablished<'a> { /// This event is always paired with an earlier /// [`FromSwarm::ConnectionEstablished`] with the same peer ID, connection ID /// and endpoint. -#[allow(deprecated)] pub struct ConnectionClosed<'a, Handler> { pub peer_id: PeerId, pub connection_id: ConnectionId, diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 40a07d30949..89fe196755d 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1300,14 +1300,6 @@ impl<'a> PollParameters for SwarmPollParameters<'a> { fn supported_protocols(&self) -> Self::SupportedProtocolsIter { self.supported_protocols.iter().cloned() } - - fn listened_addresses(&self) -> Self::ListenedAddressesIter { - self.listened_addrs.clone().into_iter().cloned() - } - - fn local_peer_id(&self) -> &PeerId { - self.local_peer_id - } } /// A [`SwarmBuilder`] provides an API for configuring and constructing a [`Swarm`]. From 8cfd73942faaf425dc0b5780362ba185e668921f Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Wed, 24 May 2023 11:11:32 +0200 Subject: [PATCH 06/11] add changelog --- swarm/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 8a7ce3707db..6c3b2069b0d 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -56,6 +56,8 @@ - Rename `ConnectionHandlerEvent::Custom` to `ConnectionHandlerEvent::NotifyBehaviour`. See [PR 3955]. +- Remove deprecated items. See [PR 3956]. + [PR 3605]: https://github.com/libp2p/rust-libp2p/pull/3605 [PR 3651]: https://github.com/libp2p/rust-libp2p/pull/3651 [PR 3715]: https://github.com/libp2p/rust-libp2p/pull/3715 @@ -70,6 +72,7 @@ [PR 3919]: https://github.com/libp2p/rust-libp2p/pull/3919 [PR 3927]: https://github.com/libp2p/rust-libp2p/pull/3927 [PR 3955]: https://github.com/libp2p/rust-libp2p/pull/3955 +[PR 3956]: https://github.com/libp2p/rust-libp2p/pull/3956 ## 0.42.2 From 67f094c86ee37c0cb758780dca4831c359e5a6c2 Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Wed, 24 May 2023 11:22:21 +0200 Subject: [PATCH 07/11] remove ListenedAddressesIter --- swarm/src/behaviour.rs | 2 -- swarm/src/lib.rs | 1 - 2 files changed, 3 deletions(-) diff --git a/swarm/src/behaviour.rs b/swarm/src/behaviour.rs index 1f26b30336c..1ddec51dfe4 100644 --- a/swarm/src/behaviour.rs +++ b/swarm/src/behaviour.rs @@ -219,8 +219,6 @@ pub trait NetworkBehaviour: 'static { pub trait PollParameters { /// Iterator returned by [`supported_protocols`](PollParameters::supported_protocols). type SupportedProtocolsIter: ExactSizeIterator>; - /// Iterator returned by [`listened_addresses`](PollParameters::listened_addresses). - type ListenedAddressesIter: ExactSizeIterator; /// Returns the list of protocol the behaviour supports when a remote negotiates a protocol on /// an inbound substream. diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 89fe196755d..269b404410f 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1295,7 +1295,6 @@ pub struct SwarmPollParameters<'a> { impl<'a> PollParameters for SwarmPollParameters<'a> { type SupportedProtocolsIter = std::iter::Cloned>>; - type ListenedAddressesIter = std::iter::Cloned>; fn supported_protocols(&self) -> Self::SupportedProtocolsIter { self.supported_protocols.iter().cloned() From 4456de05a3d7914b7ff4ed75b0bd311b9fc5037d Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Wed, 24 May 2023 11:54:54 +0200 Subject: [PATCH 08/11] fix libp2p tests with SwarmBuilder::with_async_std_executor --- libp2p/src/tutorials/ping.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libp2p/src/tutorials/ping.rs b/libp2p/src/tutorials/ping.rs index b698c6ab3bb..d899e3796f6 100644 --- a/libp2p/src/tutorials/ping.rs +++ b/libp2p/src/tutorials/ping.rs @@ -180,7 +180,7 @@ //! [`Transport`] to the [`NetworkBehaviour`]. //! //! ```rust -//! use libp2p::swarm::{keep_alive, NetworkBehaviour, Swarm}; +//! use libp2p::swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmBuilder}; //! use libp2p::{identity, ping, PeerId}; //! use std::error::Error; //! @@ -194,7 +194,7 @@ //! //! let behaviour = Behaviour::default(); //! -//! let mut swarm = Swarm::with_async_std_executor(transport, behaviour, local_peer_id); +//! let mut swarm = SwarmBuilder::with_async_std_executor(transport, behaviour, local_peer_id); //! //! Ok(()) //! } @@ -237,7 +237,7 @@ //! remote peer. //! //! ```rust -//! use libp2p::swarm::{keep_alive, NetworkBehaviour, Swarm}; +//! use libp2p::swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmBuilder}; //! use libp2p::{identity, ping, Multiaddr, PeerId}; //! use std::error::Error; //! @@ -251,7 +251,7 @@ //! //! let behaviour = Behaviour::default(); //! -//! let mut swarm = Swarm::with_async_std_executor(transport, behaviour, local_peer_id); +//! let mut swarm = SwarmBuilder::with_async_std_executor(transport, behaviour, local_peer_id).build(); //! //! // Tell the swarm to listen on all interfaces and a random, OS-assigned //! // port. @@ -287,7 +287,7 @@ //! //! ```no_run //! use futures::prelude::*; -//! use libp2p::swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmEvent}; +//! use libp2p::swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmEvent, SwarmBuilder}; //! use libp2p::{identity, ping, Multiaddr, PeerId}; //! use std::error::Error; //! @@ -301,7 +301,7 @@ //! //! let behaviour = Behaviour::default(); //! -//! let mut swarm = Swarm::with_async_std_executor(transport, behaviour, local_peer_id); +//! let mut swarm = SwarmBuilder::with_async_std_executor(transport, behaviour, local_peer_id).build(); //! //! // Tell the swarm to listen on all interfaces and a random, OS-assigned //! // port. From 242186f66b08787d53800a451baa75db92f89ebe Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Wed, 24 May 2023 14:52:59 +0200 Subject: [PATCH 09/11] remove local_peer_id and listened_addrs --- swarm/src/lib.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 269b404410f..42679c0df98 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1120,9 +1120,7 @@ where None => { let behaviour_poll = { let mut parameters = SwarmPollParameters { - local_peer_id: &this.local_peer_id, supported_protocols: &this.supported_protocols, - listened_addrs: this.listened_addrs.values().flatten().collect(), }; this.behaviour.poll(cx, &mut parameters) }; @@ -1286,11 +1284,8 @@ where /// Parameters passed to `poll()`, that the `NetworkBehaviour` has access to. // TODO: #[derive(Debug)] -#[allow(dead_code)] pub struct SwarmPollParameters<'a> { - local_peer_id: &'a PeerId, supported_protocols: &'a [Vec], - listened_addrs: Vec<&'a Multiaddr>, } impl<'a> PollParameters for SwarmPollParameters<'a> { From 971d15489828e1eec92ad091bccbb45105e94082 Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Wed, 24 May 2023 14:54:43 +0200 Subject: [PATCH 10/11] remove use Swarm from ping tutorial --- libp2p/src/tutorials/ping.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libp2p/src/tutorials/ping.rs b/libp2p/src/tutorials/ping.rs index d899e3796f6..010e5789d36 100644 --- a/libp2p/src/tutorials/ping.rs +++ b/libp2p/src/tutorials/ping.rs @@ -180,7 +180,7 @@ //! [`Transport`] to the [`NetworkBehaviour`]. //! //! ```rust -//! use libp2p::swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmBuilder}; +//! use libp2p::swarm::{keep_alive, NetworkBehaviour, SwarmBuilder}; //! use libp2p::{identity, ping, PeerId}; //! use std::error::Error; //! @@ -237,7 +237,7 @@ //! remote peer. //! //! ```rust -//! use libp2p::swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmBuilder}; +//! use libp2p::swarm::{keep_alive, NetworkBehaviour, SwarmBuilder}; //! use libp2p::{identity, ping, Multiaddr, PeerId}; //! use std::error::Error; //! @@ -287,7 +287,7 @@ //! //! ```no_run //! use futures::prelude::*; -//! use libp2p::swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmEvent, SwarmBuilder}; +//! use libp2p::swarm::{keep_alive, NetworkBehaviour, SwarmEvent, SwarmBuilder}; //! use libp2p::{identity, ping, Multiaddr, PeerId}; //! use std::error::Error; //! From 461e989f4937e40ad3c9b57dd4cce06375b1e70b Mon Sep 17 00:00:00 2001 From: Thomas Coratger <60488569+tcoratger@users.noreply.github.com> Date: Wed, 24 May 2023 14:55:55 +0200 Subject: [PATCH 11/11] Update libp2p/src/tutorials/ping.rs Co-authored-by: Thomas Eizinger --- libp2p/src/tutorials/ping.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libp2p/src/tutorials/ping.rs b/libp2p/src/tutorials/ping.rs index 010e5789d36..976b45e1e22 100644 --- a/libp2p/src/tutorials/ping.rs +++ b/libp2p/src/tutorials/ping.rs @@ -194,7 +194,7 @@ //! //! let behaviour = Behaviour::default(); //! -//! let mut swarm = SwarmBuilder::with_async_std_executor(transport, behaviour, local_peer_id); +//! let mut swarm = SwarmBuilder::with_async_std_executor(transport, behaviour, local_peer_id).build(); //! //! Ok(()) //! }