Beacon chain tasks use task executor

This commit is contained in:
pawan
2020-05-20 12:15:42 +05:30
parent 1f9e1c4808
commit 4ad39716be
19 changed files with 124 additions and 172 deletions

View File

@@ -12,3 +12,4 @@ tokio = { version = "0.2.21", features = ["full"] }
slog = "2.5.2"
parking_lot = "0.10.2"
futures = "0.3.5"
environment = { path = "../../lighthouse/environment" }

View File

@@ -13,7 +13,7 @@ use tokio::time::{interval_at, Instant};
/// Spawns a timer service which periodically executes tasks for the beacon chain
pub fn spawn<T: BeaconChainTypes>(
handle: &Handle,
handle: environment::TaskExecutor,
beacon_chain: Arc<BeaconChain<T>>,
milliseconds_per_slot: u64,
log: slog::Logger,
@@ -34,14 +34,7 @@ pub fn spawn<T: BeaconChainTypes>(
}
};
let log_1 = log.clone();
let exit_future = async move {
let _ = exit.await.ok();
info!(log_1, "Timer service shutdown");
};
let future = futures::future::select(Box::pin(timer_future), Box::pin(exit_future));
handle.spawn(future);
handle.spawn(timer_future, "timer_service");
info!(log, "Timer service started");
Ok(exit_signal)