mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-29 01:31:33 +00:00
feat(swarm): Make executor for connection tasks explicit (#3097)
Previously, the executor for connection tasks silently defaulted to a `futures::executor::ThreadPool`. This causes issues such as https://github.com/libp2p/rust-libp2p/issues/2230. With this patch, we force the user to choose, which executor they want to run the connection tasks on which results in overall simpler API with less footguns. Closes #3068.
This commit is contained in:
@ -25,7 +25,7 @@ use libp2p::multiaddr::Protocol;
|
||||
use libp2p::ping;
|
||||
use libp2p::swarm::{keep_alive, SwarmEvent};
|
||||
use libp2p::Swarm;
|
||||
use libp2p::{development_transport, rendezvous, Multiaddr};
|
||||
use libp2p::{rendezvous, tokio_development_transport, Multiaddr};
|
||||
use std::time::Duration;
|
||||
use void::Void;
|
||||
|
||||
@ -41,8 +41,8 @@ async fn main() {
|
||||
.parse()
|
||||
.unwrap();
|
||||
|
||||
let mut swarm = Swarm::new(
|
||||
development_transport(identity.clone()).await.unwrap(),
|
||||
let mut swarm = Swarm::with_tokio_executor(
|
||||
tokio_development_transport(identity.clone()).unwrap(),
|
||||
MyBehaviour {
|
||||
rendezvous: rendezvous::client::Behaviour::new(identity.clone()),
|
||||
ping: ping::Behaviour::new(ping::Config::new().with_interval(Duration::from_secs(1))),
|
||||
|
@ -24,7 +24,7 @@ use libp2p::core::PeerId;
|
||||
use libp2p::ping;
|
||||
use libp2p::swarm::{NetworkBehaviour, Swarm, SwarmEvent};
|
||||
use libp2p::Multiaddr;
|
||||
use libp2p::{development_transport, rendezvous};
|
||||
use libp2p::{rendezvous, tokio_development_transport};
|
||||
use libp2p_swarm::AddressScore;
|
||||
use std::time::Duration;
|
||||
|
||||
@ -39,8 +39,8 @@ async fn main() {
|
||||
|
||||
let identity = identity::Keypair::generate_ed25519();
|
||||
|
||||
let mut swarm = Swarm::new(
|
||||
development_transport(identity.clone()).await.unwrap(),
|
||||
let mut swarm = Swarm::with_tokio_executor(
|
||||
tokio_development_transport(identity.clone()).unwrap(),
|
||||
MyBehaviour {
|
||||
rendezvous: rendezvous::client::Behaviour::new(identity.clone()),
|
||||
ping: ping::Behaviour::new(ping::Config::new().with_interval(Duration::from_secs(1))),
|
||||
|
@ -25,7 +25,7 @@ use libp2p::identify;
|
||||
use libp2p::ping;
|
||||
use libp2p::swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmEvent};
|
||||
use libp2p::Multiaddr;
|
||||
use libp2p::{development_transport, rendezvous};
|
||||
use libp2p::{rendezvous, tokio_development_transport};
|
||||
use std::time::Duration;
|
||||
use void::Void;
|
||||
|
||||
@ -40,8 +40,8 @@ async fn main() {
|
||||
|
||||
let identity = identity::Keypair::generate_ed25519();
|
||||
|
||||
let mut swarm = Swarm::new(
|
||||
development_transport(identity.clone()).await.unwrap(),
|
||||
let mut swarm = Swarm::with_tokio_executor(
|
||||
tokio_development_transport(identity.clone()).unwrap(),
|
||||
MyBehaviour {
|
||||
identify: identify::Behaviour::new(identify::Config::new(
|
||||
"rendezvous-example/1.0.0".to_string(),
|
||||
|
@ -24,7 +24,7 @@ use libp2p::core::PeerId;
|
||||
use libp2p::identify;
|
||||
use libp2p::ping;
|
||||
use libp2p::swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmEvent};
|
||||
use libp2p::{development_transport, rendezvous};
|
||||
use libp2p::{rendezvous, tokio_development_transport};
|
||||
use void::Void;
|
||||
|
||||
/// Examples for the rendezvous protocol:
|
||||
@ -43,8 +43,8 @@ async fn main() {
|
||||
let key = identity::ed25519::SecretKey::from_bytes(bytes).expect("we always pass 32 bytes");
|
||||
let identity = identity::Keypair::Ed25519(key.into());
|
||||
|
||||
let mut swarm = Swarm::new(
|
||||
development_transport(identity.clone()).await.unwrap(),
|
||||
let mut swarm = Swarm::with_tokio_executor(
|
||||
tokio_development_transport(identity.clone()).unwrap(),
|
||||
MyBehaviour {
|
||||
identify: identify::Behaviour::new(identify::Config::new(
|
||||
"rendezvous-example/1.0.0".to_string(),
|
||||
|
Reference in New Issue
Block a user