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:
Hannes
2022-11-15 15:26:03 +01:00
committed by GitHub
parent d8fe7bf49f
commit d5ea93dd71
41 changed files with 384 additions and 181 deletions

View File

@ -70,7 +70,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let local_peer_id = PeerId::from(local_key.public());
info!("Local peer id: {:?}", local_peer_id);
let mut swarm = Swarm::new(
let mut swarm = Swarm::without_executor(
block_on(libp2p::development_transport(local_key))?,
Behaviour::default(),
local_peer_id,