mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-24 07:14:46 +00:00
Libp2p takes a TaskExecutor
This commit is contained in:
@@ -84,7 +84,7 @@ pub struct Service<TSpec: EthSpec> {
|
||||
|
||||
impl<TSpec: EthSpec> Service<TSpec> {
|
||||
pub fn new(
|
||||
handle: tokio::runtime::Handle,
|
||||
handle: environment::TaskExecutor,
|
||||
config: &NetworkConfig,
|
||||
enr_fork_id: EnrForkId,
|
||||
log: &slog::Logger,
|
||||
@@ -123,10 +123,10 @@ impl<TSpec: EthSpec> Service<TSpec> {
|
||||
let behaviour = Behaviour::new(&local_keypair, config, network_globals.clone(), &log)?;
|
||||
|
||||
// use the executor for libp2p
|
||||
struct Executor(tokio::runtime::Handle);
|
||||
struct Executor(environment::TaskExecutor);
|
||||
impl libp2p::core::Executor for Executor {
|
||||
fn exec(&self, f: Pin<Box<dyn Future<Output = ()> + Send>>) {
|
||||
self.0.spawn(f);
|
||||
self.0.spawn(f, "libp2p");
|
||||
}
|
||||
}
|
||||
SwarmBuilder::new(transport, behaviour, local_peer_id.clone())
|
||||
|
||||
@@ -73,7 +73,7 @@ impl<T: BeaconChainTypes> NetworkService<T> {
|
||||
|
||||
// launch libp2p service
|
||||
let (network_globals, mut libp2p) =
|
||||
LibP2PService::new(executor.runtime_handle(), config, enr_fork_id, &network_log)?;
|
||||
LibP2PService::new(executor.clone(), config, enr_fork_id, &network_log)?;
|
||||
|
||||
for enr in load_dht::<T::Store, T::EthSpec>(store.clone()) {
|
||||
libp2p.swarm.add_enr(enr);
|
||||
|
||||
Reference in New Issue
Block a user