chore(swarm): Remove deprecated functions (#3170)

Remove functions deprecated in 0.41.0.
This commit is contained in:
Hannes
2022-12-09 15:44:08 +01:00
committed by GitHub
parent 1c2712c1bc
commit 8cb79f4c79
22 changed files with 47 additions and 95 deletions

View File

@ -45,6 +45,11 @@
# `libp2p` facade crate # `libp2p` facade crate
# 0.51.0 [unreleased]
- Update individual crates.
- Update to [`libp2p-swarm` `v0.42.0`](swarm/CHANGELOG.md#0420).
# 0.50.0 # 0.50.0
This is a large release. After > 4 years, rust-libp2p ships with an [(alpha) QUIC This is a large release. After > 4 years, rust-libp2p ships with an [(alpha) QUIC

View File

@ -3,7 +3,7 @@ name = "libp2p"
edition = "2021" edition = "2021"
rust-version = "1.62.0" rust-version = "1.62.0"
description = "Peer-to-peer networking library" description = "Peer-to-peer networking library"
version = "0.50.0" version = "0.51.0"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT" license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p" repository = "https://github.com/libp2p/rust-libp2p"
@ -107,7 +107,7 @@ libp2p-pnet = { version = "0.22.2", path = "transports/pnet", optional = true }
libp2p-relay = { version = "0.14.0", path = "protocols/relay", optional = true } libp2p-relay = { version = "0.14.0", path = "protocols/relay", optional = true }
libp2p-rendezvous = { version = "0.11.0", path = "protocols/rendezvous", optional = true } libp2p-rendezvous = { version = "0.11.0", path = "protocols/rendezvous", optional = true }
libp2p-request-response = { version = "0.23.0", path = "protocols/request-response", optional = true } libp2p-request-response = { version = "0.23.0", path = "protocols/request-response", optional = true }
libp2p-swarm = { version = "0.41.0", path = "swarm" } libp2p-swarm = { version = "0.42.0", path = "swarm" }
libp2p-uds = { version = "0.37.0", path = "transports/uds", optional = true } libp2p-uds = { version = "0.37.0", path = "transports/uds", optional = true }
libp2p-wasm-ext = { version = "0.38.0", path = "transports/wasm-ext", optional = true } libp2p-wasm-ext = { version = "0.38.0", path = "transports/wasm-ext", optional = true }
libp2p-yamux = { version = "0.42.0", path = "muxers/yamux", optional = true } libp2p-yamux = { version = "0.42.0", path = "muxers/yamux", optional = true }

View File

@ -25,7 +25,7 @@ libp2p-identify = { version = "0.41.0", path = "../../protocols/identify", optio
libp2p-kad = { version = "0.42.0", path = "../../protocols/kad", optional = true } libp2p-kad = { version = "0.42.0", path = "../../protocols/kad", optional = true }
libp2p-ping = { version = "0.41.0", path = "../../protocols/ping", optional = true } libp2p-ping = { version = "0.41.0", path = "../../protocols/ping", optional = true }
libp2p-relay = { version = "0.14.0", path = "../../protocols/relay", optional = true } libp2p-relay = { version = "0.14.0", path = "../../protocols/relay", optional = true }
libp2p-swarm = { version = "0.41.0", path = "../../swarm" } libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
prometheus-client = "0.18.0" prometheus-client = "0.18.0"
[target.'cfg(not(target_os = "unknown"))'.dependencies] [target.'cfg(not(target_os = "unknown"))'.dependencies]
@ -39,7 +39,7 @@ libp2p = { path = "../..", features = ["full"] }
hyper = { version="0.14", features = ["server", "tcp", "http1"] } hyper = { version="0.14", features = ["server", "tcp", "http1"] }
tokio = { version = "1", features = ["rt-multi-thread"] } tokio = { version = "1", features = ["rt-multi-thread"] }
# Passing arguments to the docsrs builder in order to properly document cfg's. # Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling # More information: https://docs.rs/about/builds#cross-compiling
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

View File

@ -19,7 +19,7 @@ futures = "0.3"
futures-timer = "3.0" futures-timer = "3.0"
instant = "0.1" instant = "0.1"
libp2p-core = { version = "0.38.0", path = "../../core" } libp2p-core = { version = "0.38.0", path = "../../core" }
libp2p-swarm = { version = "0.41.0", path = "../../swarm" } libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
libp2p-request-response = { version = "0.23.0", path = "../request-response" } libp2p-request-response = { version = "0.23.0", path = "../request-response" }
log = "0.4" log = "0.4"
rand = "0.8" rand = "0.8"
@ -31,7 +31,7 @@ env_logger = "0.10"
clap = { version = "4.0.13", features = ["derive"] } clap = { version = "4.0.13", features = ["derive"] }
libp2p = { path = "../..", features = ["full"] } libp2p = { path = "../..", features = ["full"] }
# Passing arguments to the docsrs builder in order to properly document cfg's. # Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling # More information: https://docs.rs/about/builds#cross-compiling
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

View File

@ -18,7 +18,7 @@ futures = "0.3.1"
futures-timer = "3.0" futures-timer = "3.0"
instant = "0.1.11" instant = "0.1.11"
libp2p-core = { version = "0.38.0", path = "../../core" } libp2p-core = { version = "0.38.0", path = "../../core" }
libp2p-swarm = { version = "0.41.0", path = "../../swarm" } libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
log = "0.4" log = "0.4"
prost-codec = { version = "0.3", path = "../../misc/prost-codec" } prost-codec = { version = "0.3", path = "../../misc/prost-codec" }
prost = "0.11" prost = "0.11"
@ -34,7 +34,7 @@ libp2p = { path = "../..", features = ["full"] }
rand = "0.8" rand = "0.8"
clap = { version = "4.0.13", features = ["derive"] } clap = { version = "4.0.13", features = ["derive"] }
# Passing arguments to the docsrs builder in order to properly document cfg's. # Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling # More information: https://docs.rs/about/builds#cross-compiling
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

View File

@ -15,7 +15,7 @@ cuckoofilter = "0.5.0"
fnv = "1.0" fnv = "1.0"
futures = "0.3.1" futures = "0.3.1"
libp2p-core = { version = "0.38.0", path = "../../core" } libp2p-core = { version = "0.38.0", path = "../../core" }
libp2p-swarm = { version = "0.41.0", path = "../../swarm" } libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
log = "0.4" log = "0.4"
prost = "0.11" prost = "0.11"
rand = "0.8" rand = "0.8"
@ -25,7 +25,7 @@ thiserror = "1.0.37"
[build-dependencies] [build-dependencies]
prost-build = "0.11" prost-build = "0.11"
# Passing arguments to the docsrs builder in order to properly document cfg's. # Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling # More information: https://docs.rs/about/builds#cross-compiling
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

View File

@ -11,7 +11,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
[dependencies] [dependencies]
libp2p-swarm = { version = "0.41.0", path = "../../swarm" } libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
libp2p-core = { version = "0.38.0", path = "../../core" } libp2p-core = { version = "0.38.0", path = "../../core" }
bytes = "1.0" bytes = "1.0"
byteorder = "1.3.4" byteorder = "1.3.4"
@ -46,7 +46,7 @@ derive_builder = "0.11.1"
[build-dependencies] [build-dependencies]
prost-build = "0.11" prost-build = "0.11"
# Passing arguments to the docsrs builder in order to properly document cfg's. # Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling # More information: https://docs.rs/about/builds#cross-compiling
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

View File

@ -121,8 +121,8 @@
//! libp2p_gossipsub::Gossipsub::new(message_authenticity, gossipsub_config).unwrap(); //! libp2p_gossipsub::Gossipsub::new(message_authenticity, gossipsub_config).unwrap();
//! // subscribe to the topic //! // subscribe to the topic
//! gossipsub.subscribe(&topic); //! gossipsub.subscribe(&topic);
//! // create the swarm //! // create the swarm (use an executor in a real example)
//! libp2p_swarm::Swarm::new( //! libp2p_swarm::Swarm::without_executor(
//! transport, //! transport,
//! gossipsub, //! gossipsub,
//! local_peer_id, //! local_peer_id,

View File

@ -15,7 +15,7 @@ asynchronous-codec = "0.6"
futures = "0.3.1" futures = "0.3.1"
futures-timer = "3.0.2" futures-timer = "3.0.2"
libp2p-core = { version = "0.38.0", path = "../../core" } libp2p-core = { version = "0.38.0", path = "../../core" }
libp2p-swarm = { version = "0.41.0", path = "../../swarm" } libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
log = "0.4.1" log = "0.4.1"
lru = "0.8.0" lru = "0.8.0"
prost-codec = { version = "0.3", path = "../../misc/prost-codec" } prost-codec = { version = "0.3", path = "../../misc/prost-codec" }
@ -32,7 +32,7 @@ libp2p = { path = "../..", features = ["full"] }
[build-dependencies] [build-dependencies]
prost-build = "0.11" prost-build = "0.11"
# Passing arguments to the docsrs builder in order to properly document cfg's. # Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling # More information: https://docs.rs/about/builds#cross-compiling
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

View File

@ -19,7 +19,7 @@ asynchronous-codec = "0.6"
futures = "0.3.1" futures = "0.3.1"
log = "0.4" log = "0.4"
libp2p-core = { version = "0.38.0", path = "../../core" } libp2p-core = { version = "0.38.0", path = "../../core" }
libp2p-swarm = { version = "0.41.0", path = "../../swarm" } libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
prost = "0.11" prost = "0.11"
rand = "0.8" rand = "0.8"
sha2 = "0.10.0" sha2 = "0.10.0"
@ -44,7 +44,7 @@ prost-build = "0.11"
[features] [features]
serde = ["dep:serde", "bytes/serde"] serde = ["dep:serde", "bytes/serde"]
# Passing arguments to the docsrs builder in order to properly document cfg's. # Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling # More information: https://docs.rs/about/builds#cross-compiling
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

View File

@ -16,7 +16,7 @@ data-encoding = "2.3.2"
futures = "0.3.13" futures = "0.3.13"
if-watch = "3.0.0" if-watch = "3.0.0"
libp2p-core = { version = "0.38.0", path = "../../core" } libp2p-core = { version = "0.38.0", path = "../../core" }
libp2p-swarm = { version = "0.41.0", path = "../../swarm" } libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
log = "0.4.14" log = "0.4.14"
rand = "0.8.3" rand = "0.8.3"
smallvec = "1.6.1" smallvec = "1.6.1"
@ -45,7 +45,7 @@ name = "use-tokio"
required-features = ["tokio"] required-features = ["tokio"]
# Passing arguments to the docsrs builder in order to properly document cfg's. # Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling # More information: https://docs.rs/about/builds#cross-compiling
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

View File

@ -15,7 +15,7 @@ futures = "0.3.1"
futures-timer = "3.0.2" futures-timer = "3.0.2"
instant = "0.1.11" instant = "0.1.11"
libp2p-core = { version = "0.38.0", path = "../../core" } libp2p-core = { version = "0.38.0", path = "../../core" }
libp2p-swarm = { version = "0.41.0", path = "../../swarm" } libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
log = "0.4.1" log = "0.4.1"
rand = "0.8" rand = "0.8"
void = "1.0" void = "1.0"
@ -25,7 +25,7 @@ async-std = "1.6.2"
libp2p = { path = "../..", features = ["full"] } libp2p = { path = "../..", features = ["full"] }
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" } quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }
# Passing arguments to the docsrs builder in order to properly document cfg's. # Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling # More information: https://docs.rs/about/builds#cross-compiling
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

View File

@ -18,7 +18,7 @@ futures = "0.3.1"
futures-timer = "3" futures-timer = "3"
instant = "0.1.11" instant = "0.1.11"
libp2p-core = { version = "0.38.0", path = "../../core" } libp2p-core = { version = "0.38.0", path = "../../core" }
libp2p-swarm = { version = "0.41.0", path = "../../swarm" } libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
log = "0.4" log = "0.4"
pin-project = "1" pin-project = "1"
prost-codec = { version = "0.3", path = "../../misc/prost-codec" } prost-codec = { version = "0.3", path = "../../misc/prost-codec" }
@ -38,7 +38,7 @@ libp2p = { path = "../..", features = ["full"] }
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" } quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }
clap = { version = "4.0.13", features = ["derive"] } clap = { version = "4.0.13", features = ["derive"] }
# Passing arguments to the docsrs builder in order to properly document cfg's. # Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling # More information: https://docs.rs/about/builds#cross-compiling
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

View File

@ -17,7 +17,7 @@ futures = { version = "0.3", default-features = false, features = ["std"] }
futures-timer = "3.0.2" futures-timer = "3.0.2"
instant = "0.1.11" instant = "0.1.11"
libp2p-core = { version = "0.38.0", path = "../../core" } libp2p-core = { version = "0.38.0", path = "../../core" }
libp2p-swarm = { version = "0.41.0", path = "../../swarm" } libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
log = "0.4" log = "0.4"
prost = "0.11" prost = "0.11"
prost-codec = { version = "0.3.0", path = "../../misc/prost-codec" } prost-codec = { version = "0.3.0", path = "../../misc/prost-codec" }
@ -37,7 +37,7 @@ tokio = { version = "1.15", features = [ "rt-multi-thread", "time", "macros", "s
[build-dependencies] [build-dependencies]
prost-build = "0.11" prost-build = "0.11"
# Passing arguments to the docsrs builder in order to properly document cfg's. # Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling # More information: https://docs.rs/about/builds#cross-compiling
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

View File

@ -16,7 +16,7 @@ bytes = "1"
futures = "0.3.1" futures = "0.3.1"
instant = "0.1.11" instant = "0.1.11"
libp2p-core = { version = "0.38.0", path = "../../core" } libp2p-core = { version = "0.38.0", path = "../../core" }
libp2p-swarm = { version = "0.41.0", path = "../../swarm" } libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
log = "0.4.11" log = "0.4.11"
rand = "0.8" rand = "0.8"
smallvec = "1.6.1" smallvec = "1.6.1"
@ -28,7 +28,7 @@ env_logger = "0.10.0"
libp2p = { path = "../..", features = ["full"] } libp2p = { path = "../..", features = ["full"] }
rand = "0.8" rand = "0.8"
# Passing arguments to the docsrs builder in order to properly document cfg's. # Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling # More information: https://docs.rs/about/builds#cross-compiling
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true

View File

@ -193,7 +193,7 @@
//! // can be observed. //! // can be observed.
//! let behaviour = ping::Behaviour::new(ping::Config::new().with_keep_alive(true)); //! let behaviour = ping::Behaviour::new(ping::Config::new().with_keep_alive(true));
//! //!
//! let mut swarm = Swarm::new(transport, behaviour, local_peer_id); //! let mut swarm = Swarm::with_async_std_executor(transport, behaviour, local_peer_id);
//! //!
//! Ok(()) //! Ok(())
//! } //! }
@ -245,7 +245,7 @@
//! // can be observed. //! // can be observed.
//! let behaviour = ping::Behaviour::new(ping::Config::new().with_keep_alive(true)); //! let behaviour = ping::Behaviour::new(ping::Config::new().with_keep_alive(true));
//! //!
//! let mut swarm = Swarm::new(transport, behaviour, local_peer_id); //! let mut swarm = Swarm::with_async_std_executor(transport, behaviour, local_peer_id);
//! //!
//! // Tell the swarm to listen on all interfaces and a random, OS-assigned //! // Tell the swarm to listen on all interfaces and a random, OS-assigned
//! // port. //! // port.
@ -290,7 +290,7 @@
//! // can be observed. //! // can be observed.
//! let behaviour = ping::Behaviour::new(ping::Config::new().with_keep_alive(true)); //! let behaviour = ping::Behaviour::new(ping::Config::new().with_keep_alive(true));
//! //!
//! let mut swarm = Swarm::new(transport, behaviour, local_peer_id); //! let mut swarm = Swarm::with_async_std_executor(transport, behaviour, local_peer_id);
//! //!
//! // Tell the swarm to listen on all interfaces and a random, OS-assigned //! // Tell the swarm to listen on all interfaces and a random, OS-assigned
//! // port. //! // port.

View File

@ -1,3 +1,9 @@
# 0.42.0 [unreleased]
- Removed deprecated Swarm constructors. For transition notes see [0.41.0](#0.41.0). See [PR 3170].
[PR 3170]: https://github.com/libp2p/rust-libp2p/pull/3170
# 0.41.1 # 0.41.1
- Update to `libp2p-swarm-derive` `v0.31.0`. - Update to `libp2p-swarm-derive` `v0.31.0`.

View File

@ -3,7 +3,7 @@ name = "libp2p-swarm"
edition = "2021" edition = "2021"
rust-version = "1.62.0" rust-version = "1.62.0"
description = "The libp2p swarm" description = "The libp2p swarm"
version = "0.41.1" version = "0.42.0"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT" license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p" repository = "https://github.com/libp2p/rust-libp2p"

View File

@ -471,7 +471,7 @@ pub enum NetworkBehaviourAction<
/// # .multiplex(yamux::YamuxConfig::default()) /// # .multiplex(yamux::YamuxConfig::default())
/// # .boxed(); /// # .boxed();
/// # /// #
/// # let mut swarm = Swarm::new(transport, MyBehaviour::default(), local_peer_id); /// # let mut swarm = Swarm::with_threadpool_executor(transport, MyBehaviour::default(), local_peer_id);
/// # /// #
/// // Super precious message that we should better not lose. /// // Super precious message that we should better not lose.
/// let message = PreciousMessage("My precious message".to_string()); /// let message = PreciousMessage("My precious message".to_string());

View File

@ -1102,12 +1102,6 @@ impl PoolConfig {
} }
} }
/// Configures the executor to use for spawning connection background tasks.
pub fn with_executor(mut self, executor: Box<dyn Executor + Send>) -> Self {
self.executor = Some(executor);
self
}
/// Sets the maximum number of events sent to a connection's background task /// Sets the maximum number of events sent to a connection's background task
/// that may be buffered, if the task cannot keep up with their consumption and /// that may be buffered, if the task cannot keep up with their consumption and
/// delivery to the connection handler. /// delivery to the connection handler.

View File

@ -39,7 +39,7 @@ pub struct TokioExecutor;
))] ))]
impl Executor for TokioExecutor { impl Executor for TokioExecutor {
fn exec(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>) { fn exec(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>) {
let _ = tokio::spawn(future); tokio::spawn(future);
} }
} }
@ -56,7 +56,7 @@ pub struct AsyncStdExecutor;
))] ))]
impl Executor for AsyncStdExecutor { impl Executor for AsyncStdExecutor {
fn exec(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>) { fn exec(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>) {
let _ = async_std::task::spawn(future); async_std::task::spawn(future);
} }
} }

View File

@ -342,19 +342,6 @@ impl<TBehaviour> Swarm<TBehaviour>
where where
TBehaviour: NetworkBehaviour, TBehaviour: NetworkBehaviour,
{ {
/// Builds a new `Swarm`.
#[deprecated(
since = "0.41.0",
note = "This constructor is considered ambiguous regarding the executor. Use one of the new, executor-specific constructors or `Swarm::with_threadpool_executor` for the same behaviour."
)]
pub fn new(
transport: transport::Boxed<(PeerId, StreamMuxerBox)>,
behaviour: TBehaviour,
local_peer_id: PeerId,
) -> Self {
Self::with_threadpool_executor(transport, behaviour, local_peer_id)
}
/// Builds a new `Swarm` with a provided executor. /// Builds a new `Swarm` with a provided executor.
pub fn with_executor( pub fn with_executor(
transport: transport::Boxed<(PeerId, StreamMuxerBox)>, transport: transport::Boxed<(PeerId, StreamMuxerBox)>,
@ -498,7 +485,7 @@ where
/// # use libp2p_core::transport::dummy::DummyTransport; /// # use libp2p_core::transport::dummy::DummyTransport;
/// # use libp2p_swarm::dummy; /// # use libp2p_swarm::dummy;
/// # /// #
/// let mut swarm = Swarm::new( /// let mut swarm = Swarm::without_executor(
/// DummyTransport::new().boxed(), /// DummyTransport::new().boxed(),
/// dummy::Behaviour, /// dummy::Behaviour,
/// PeerId::random(), /// PeerId::random(),
@ -1432,35 +1419,6 @@ impl<TBehaviour> SwarmBuilder<TBehaviour>
where where
TBehaviour: NetworkBehaviour, TBehaviour: NetworkBehaviour,
{ {
/// Creates a new `SwarmBuilder` from the given transport, behaviour and
/// local peer ID. The `Swarm` with its underlying `Network` is obtained
/// via [`SwarmBuilder::build`].
#[deprecated(
since = "0.41.0",
note = "Use `SwarmBuilder::with_executor` or `SwarmBuilder::without_executor` instead."
)]
pub fn new(
transport: transport::Boxed<(PeerId, StreamMuxerBox)>,
behaviour: TBehaviour,
local_peer_id: PeerId,
) -> Self {
let executor: Option<Box<dyn Executor + Send>> = match ThreadPoolBuilder::new()
.name_prefix("libp2p-swarm-task-")
.create()
.ok()
{
Some(tp) => Some(Box::new(tp)),
None => None,
};
SwarmBuilder {
local_peer_id,
transport,
behaviour,
pool_config: PoolConfig::new(executor),
connection_limits: Default::default(),
}
}
/// Creates a new [`SwarmBuilder`] from the given transport, behaviour, local peer ID and /// Creates a new [`SwarmBuilder`] from the given transport, behaviour, local peer ID and
/// executor. The `Swarm` with its underlying `Network` is obtained via /// executor. The `Swarm` with its underlying `Network` is obtained via
/// [`SwarmBuilder::build`]. /// [`SwarmBuilder::build`].
@ -1538,17 +1496,6 @@ where
} }
} }
/// Configures the `Executor` to use for spawning background tasks.
///
/// By default, unless another executor has been configured,
/// [`SwarmBuilder::build`] will try to set up a
/// [`ThreadPool`](futures::executor::ThreadPool).
#[deprecated(since = "0.41.0", note = "Use `SwarmBuilder::with_executor` instead.")]
pub fn executor(mut self, executor: Box<dyn Executor + Send>) -> Self {
self.pool_config = self.pool_config.with_executor(executor);
self
}
/// Configures the number of events from the [`NetworkBehaviour`] in /// Configures the number of events from the [`NetworkBehaviour`] in
/// destination to the [`ConnectionHandler`] that can be buffered before /// destination to the [`ConnectionHandler`] that can be buffered before
/// the [`Swarm`] has to wait. An individual buffer with this number of /// the [`Swarm`] has to wait. An individual buffer with this number of