Validator client tasks use task executor

This commit is contained in:
pawan
2020-05-20 12:15:55 +05:30
parent 4ad39716be
commit 6d3503c05f
6 changed files with 42 additions and 87 deletions

View File

@@ -1,9 +1,8 @@
use environment::RuntimeContext;
use exit_future::Signal;
use futures::{FutureExt, StreamExt};
use futures::StreamExt;
use parking_lot::RwLock;
use remote_beacon_node::RemoteBeaconNode;
use slog::{debug, info, trace};
use slog::{debug, trace};
use slot_clock::SlotClock;
use std::ops::Deref;
use std::sync::Arc;
@@ -100,9 +99,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ForkService<T, E> {
}
/// Starts the service that periodically polls for the `Fork`.
pub fn start_update_service(self, spec: &ChainSpec) -> Result<Signal, String> {
let log = self.context.log.clone();
pub fn start_update_service(self, spec: &ChainSpec) -> Result<(), String> {
let duration_to_next_epoch = self
.slot_clock
.duration_to_next_epoch(E::slots_per_epoch())
@@ -117,12 +114,11 @@ impl<T: SlotClock + 'static, E: EthSpec> ForkService<T, E> {
)
};
let (exit_signal, exit_fut) = exit_future::signal();
// Run an immediate update before starting the updater service.
self.inner
.context
.runtime_handle
.runtime_handle()
.spawn(self.clone().do_update());
let runtime_handle = self.inner.context.runtime_handle.clone();
@@ -133,13 +129,9 @@ impl<T: SlotClock + 'static, E: EthSpec> ForkService<T, E> {
}
};
let future = futures::future::select(
Box::pin(interval_fut),
exit_fut.map(move |_| info!(log, "Shutdown complete")),
);
runtime_handle.spawn(future);
runtime_handle.spawn(interval_fut, "fork_service");
Ok(exit_signal)
Ok(())
}
/// Attempts to download the `Fork` from the server.