mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-22 14:21: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:
@ -62,7 +62,7 @@ async fn create_swarm(config: MdnsConfig) -> Result<Swarm<Mdns>, Box<dyn Error>>
|
||||
let peer_id = PeerId::from(id_keys.public());
|
||||
let transport = libp2p::development_transport(id_keys).await?;
|
||||
let behaviour = Mdns::new(config)?;
|
||||
let mut swarm = Swarm::new(transport, behaviour, peer_id);
|
||||
let mut swarm = Swarm::with_async_std_executor(transport, behaviour, peer_id);
|
||||
swarm.listen_on("/ip4/0.0.0.0/tcp/0".parse()?)?;
|
||||
Ok(swarm)
|
||||
}
|
||||
|
Reference in New Issue
Block a user