mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-24 07:11:38 +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:
@ -219,9 +219,7 @@ mod network {
|
||||
ProtocolSupport, RequestId, RequestResponse, RequestResponseCodec, RequestResponseEvent,
|
||||
RequestResponseMessage, ResponseChannel,
|
||||
};
|
||||
use libp2p::swarm::{
|
||||
ConnectionHandlerUpgrErr, NetworkBehaviour, Swarm, SwarmBuilder, SwarmEvent,
|
||||
};
|
||||
use libp2p::swarm::{ConnectionHandlerUpgrErr, NetworkBehaviour, Swarm, SwarmEvent};
|
||||
use std::collections::{hash_map, HashMap, HashSet};
|
||||
use std::iter;
|
||||
|
||||
@ -252,7 +250,7 @@ mod network {
|
||||
|
||||
// Build the Swarm, connecting the lower layer transport logic with the
|
||||
// higher layer network behaviour logic.
|
||||
let swarm = SwarmBuilder::new(
|
||||
let swarm = Swarm::with_threadpool_executor(
|
||||
libp2p::development_transport(id_keys).await?,
|
||||
ComposedBehaviour {
|
||||
kademlia: Kademlia::new(peer_id, MemoryStore::new(peer_id)),
|
||||
@ -263,8 +261,7 @@ mod network {
|
||||
),
|
||||
},
|
||||
peer_id,
|
||||
)
|
||||
.build();
|
||||
);
|
||||
|
||||
let (command_sender, command_receiver) = mpsc::channel(0);
|
||||
let (event_sender, event_receiver) = mpsc::channel(0);
|
||||
|
Reference in New Issue
Block a user