mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 21:38:31 +00:00
Rename runtime_handle to executor
This commit is contained in:
@@ -222,7 +222,7 @@ where
|
||||
.clone();
|
||||
|
||||
let (network_globals, network_send) =
|
||||
NetworkService::start(beacon_chain, config, context.runtime_handle, context.log)
|
||||
NetworkService::start(beacon_chain, config, context.executor, context.log)
|
||||
.map_err(|e| format!("Failed to start network: {:?}", e))?;
|
||||
|
||||
self.network_globals = Some(network_globals);
|
||||
@@ -249,7 +249,7 @@ where
|
||||
.milliseconds_per_slot;
|
||||
|
||||
let _ = timer::spawn(
|
||||
context.runtime_handle,
|
||||
context.executor,
|
||||
beacon_chain,
|
||||
milliseconds_per_slot,
|
||||
context.log.clone(),
|
||||
@@ -290,7 +290,7 @@ where
|
||||
|
||||
let log = context.log.clone();
|
||||
let listening_addr = rest_api::start_server(
|
||||
context.runtime_handle,
|
||||
context.executor,
|
||||
&client_config.rest_api,
|
||||
beacon_chain,
|
||||
network_info,
|
||||
@@ -332,7 +332,7 @@ where
|
||||
.milliseconds_per_slot;
|
||||
|
||||
let _ = spawn_notifier(
|
||||
context.runtime_handle,
|
||||
context.executor,
|
||||
beacon_chain,
|
||||
network_globals,
|
||||
milliseconds_per_slot,
|
||||
@@ -428,7 +428,7 @@ where
|
||||
|
||||
let (sender, listening_addr): (WebSocketSender<TEthSpec>, Option<_>) = if config.enabled {
|
||||
let (sender, listening_addr) =
|
||||
websocket_server::start_server(context.runtime_handle, &config, &context.log)?;
|
||||
websocket_server::start_server(context.executor, &config, &context.log)?;
|
||||
(sender, Some(listening_addr))
|
||||
} else {
|
||||
(WebSocketSender::dummy(), None)
|
||||
@@ -638,7 +638,7 @@ where
|
||||
self.eth1_service = None;
|
||||
|
||||
// Starts the service that connects to an eth1 node and periodically updates caches.
|
||||
backend.start(context.runtime_handle);
|
||||
backend.start(context.executor);
|
||||
|
||||
self.beacon_chain_builder = Some(beacon_chain_builder.eth1_backend(Some(backend)));
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ const SPEEDO_OBSERVATIONS: usize = 4;
|
||||
|
||||
/// Spawns a notifier service which periodically logs information about the node.
|
||||
pub fn spawn_notifier<T: BeaconChainTypes>(
|
||||
handle: environment::TaskExecutor,
|
||||
executor: environment::TaskExecutor,
|
||||
beacon_chain: Arc<BeaconChain<T>>,
|
||||
network: Arc<NetworkGlobals<T::EthSpec>>,
|
||||
milliseconds_per_slot: u64,
|
||||
@@ -149,7 +149,7 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
|
||||
};
|
||||
|
||||
// run the notifier on the current executor
|
||||
handle.spawn(interval_future.unwrap_or_else(|_| ()), "beacon_notifier");
|
||||
executor.spawn(interval_future.unwrap_or_else(|_| ()), "beacon_notifier");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ impl<T: BeaconChainTypes> NetworkService<T> {
|
||||
pub fn start(
|
||||
beacon_chain: Arc<BeaconChain<T>>,
|
||||
config: &NetworkConfig,
|
||||
handle: environment::TaskExecutor,
|
||||
executor: environment::TaskExecutor,
|
||||
network_log: slog::Logger,
|
||||
) -> error::Result<(
|
||||
Arc<NetworkGlobals<T::EthSpec>>,
|
||||
@@ -74,7 +74,7 @@ impl<T: BeaconChainTypes> NetworkService<T> {
|
||||
|
||||
// launch libp2p service
|
||||
let (network_globals, mut libp2p) =
|
||||
LibP2PService::new(handle.runtime_handle(), config, enr_fork_id, &network_log)?;
|
||||
LibP2PService::new(executor.runtime_handle(), config, enr_fork_id, &network_log)?;
|
||||
|
||||
for enr in load_dht::<T::Store, T::EthSpec>(store.clone()) {
|
||||
libp2p.swarm.add_enr(enr);
|
||||
@@ -87,7 +87,7 @@ impl<T: BeaconChainTypes> NetworkService<T> {
|
||||
beacon_chain.clone(),
|
||||
network_globals.clone(),
|
||||
network_send.clone(),
|
||||
handle.clone(),
|
||||
executor.clone(),
|
||||
network_log.clone(),
|
||||
)?;
|
||||
|
||||
@@ -110,21 +110,20 @@ impl<T: BeaconChainTypes> NetworkService<T> {
|
||||
propagation_percentage,
|
||||
};
|
||||
|
||||
let _ = spawn_service(handle, network_service)?;
|
||||
let _ = spawn_service(executor, network_service)?;
|
||||
|
||||
Ok((network_globals, network_send))
|
||||
}
|
||||
}
|
||||
|
||||
fn spawn_service<T: BeaconChainTypes>(
|
||||
handle: environment::TaskExecutor,
|
||||
executor: environment::TaskExecutor,
|
||||
mut service: NetworkService<T>,
|
||||
) -> error::Result<()> {
|
||||
let mut exit_rx = handle.exit();
|
||||
let handle = handle.runtime_handle();
|
||||
let mut exit_rx = executor.exit();
|
||||
|
||||
// spawn on the current executor
|
||||
handle.spawn(async move {
|
||||
executor.runtime_handle().spawn(async move {
|
||||
loop {
|
||||
// build the futures to check simultaneously
|
||||
tokio::select! {
|
||||
|
||||
@@ -52,7 +52,7 @@ pub struct NetworkInfo<T: BeaconChainTypes> {
|
||||
// Allowing more than 7 arguments.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn start_server<T: BeaconChainTypes>(
|
||||
handle: environment::TaskExecutor,
|
||||
executor: environment::TaskExecutor,
|
||||
config: &Config,
|
||||
beacon_chain: Arc<BeaconChain<T>>,
|
||||
network_info: NetworkInfo<T>,
|
||||
@@ -100,7 +100,7 @@ pub fn start_server<T: BeaconChainTypes>(
|
||||
let actual_listen_addr = server.local_addr();
|
||||
|
||||
// Build a channel to kill the HTTP server.
|
||||
let exit = handle.exit();
|
||||
let exit = executor.exit();
|
||||
let inner_log = log.clone();
|
||||
let server_exit = async move {
|
||||
let _ = exit.await;
|
||||
@@ -127,7 +127,7 @@ pub fn start_server<T: BeaconChainTypes>(
|
||||
"port" => actual_listen_addr.port(),
|
||||
);
|
||||
|
||||
handle.runtime_handle().spawn(server_future);
|
||||
executor.runtime_handle().spawn(server_future);
|
||||
|
||||
Ok(actual_listen_addr)
|
||||
}
|
||||
|
||||
@@ -13,13 +13,11 @@ use tokio::time::{interval_at, Instant};
|
||||
|
||||
/// Spawns a timer service which periodically executes tasks for the beacon chain
|
||||
pub fn spawn<T: BeaconChainTypes>(
|
||||
handle: environment::TaskExecutor,
|
||||
executor: environment::TaskExecutor,
|
||||
beacon_chain: Arc<BeaconChain<T>>,
|
||||
milliseconds_per_slot: u64,
|
||||
log: slog::Logger,
|
||||
) -> Result<tokio::sync::oneshot::Sender<()>, &'static str> {
|
||||
let (exit_signal, exit) = tokio::sync::oneshot::channel();
|
||||
|
||||
) -> Result<(), &'static str> {
|
||||
let start_instant = Instant::now()
|
||||
+ beacon_chain
|
||||
.slot_clock
|
||||
@@ -34,8 +32,8 @@ pub fn spawn<T: BeaconChainTypes>(
|
||||
}
|
||||
};
|
||||
|
||||
handle.spawn(timer_future, "timer_service");
|
||||
executor.spawn(timer_future, "timer_service");
|
||||
info!(log, "Timer service started");
|
||||
|
||||
Ok(exit_signal)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ impl<T: EthSpec> WebSocketSender<T> {
|
||||
}
|
||||
|
||||
pub fn start_server<T: EthSpec>(
|
||||
handle: environment::TaskExecutor,
|
||||
executor: environment::TaskExecutor,
|
||||
config: &Config,
|
||||
log: &Logger,
|
||||
) -> Result<(WebSocketSender<T>, SocketAddr), String> {
|
||||
@@ -61,7 +61,7 @@ pub fn start_server<T: EthSpec>(
|
||||
let broadcaster = server.broadcaster();
|
||||
|
||||
// Produce a signal/channel that can gracefully shutdown the websocket server.
|
||||
let exit = handle.exit();
|
||||
let exit = executor.exit();
|
||||
let log_inner = log.clone();
|
||||
let broadcaster_inner = server.broadcaster();
|
||||
let exit_future = async move {
|
||||
@@ -79,7 +79,7 @@ pub fn start_server<T: EthSpec>(
|
||||
|
||||
// Place a future on the handle that will shutdown the websocket server when the
|
||||
// application exits.
|
||||
handle.runtime_handle().spawn(exit_future);
|
||||
executor.runtime_handle().spawn(exit_future);
|
||||
|
||||
let log_inner = log.clone();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user