Rename runtime_handle to executor

This commit is contained in:
pawan
2020-05-20 13:00:39 +05:30
parent 6d3503c05f
commit 8be6a4ecd5
13 changed files with 51 additions and 57 deletions

View File

@@ -3,7 +3,7 @@ use crate::{
validator_store::ValidatorStore,
};
use environment::RuntimeContext;
use futures::{StreamExt, TryFutureExt};
use futures::StreamExt;
use remote_beacon_node::{PublishStatus, RemoteBeaconNode};
use slog::{crit, debug, info, trace};
use slot_clock::SlotClock;
@@ -140,7 +140,7 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
)
};
let runtime_handle = self.context.runtime_handle.clone();
let executor = self.context.executor.clone();
let interval_fut = async move {
while interval.next().await.is_some() {
@@ -161,7 +161,7 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
}
};
runtime_handle.spawn(interval_fut, "attestation_service");
executor.spawn(interval_fut, "attestation_service");
Ok(())
}
@@ -206,16 +206,13 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
.into_iter()
.for_each(|(committee_index, validator_duties)| {
// Spawn a separate task for each attestation.
self.inner.context.runtime_handle.spawn(
self.clone()
.publish_attestations_and_aggregates(
slot,
committee_index,
validator_duties,
aggregate_production_instant,
)
.unwrap_or_else(|_| ()),
"duties_by_committee_index",
self.inner.context.executor.runtime_handle().spawn(
self.clone().publish_attestations_and_aggregates(
slot,
committee_index,
validator_duties,
aggregate_production_instant,
),
);
});

View File

@@ -135,7 +135,7 @@ impl<T: SlotClock + 'static, E: EthSpec> BlockService<T, E> {
)
};
let runtime_handle = self.inner.context.runtime_handle.clone();
let executor = self.inner.context.executor.clone();
let interval_fut = async move {
while interval.next().await.is_some() {
@@ -143,7 +143,7 @@ impl<T: SlotClock + 'static, E: EthSpec> BlockService<T, E> {
}
};
runtime_handle.spawn(interval_fut, "block_service");
executor.spawn(interval_fut, "block_service");
Ok(())
}
@@ -184,7 +184,7 @@ impl<T: SlotClock + 'static, E: EthSpec> BlockService<T, E> {
let service = self.clone();
let log = log.clone();
// TODO: run this task with a `spawn_without_name`
self.inner.context.runtime_handle.spawn(
self.inner.context.executor.spawn(
service
.publish_block(slot, validator_pubkey)
.map_err(move |e| {

View File

@@ -456,11 +456,11 @@ impl<T: SlotClock + 'static, E: EthSpec> DutiesService<T, E> {
// Run an immediate update before starting the updater service.
self.inner
.context
.runtime_handle
.executor
.runtime_handle()
.spawn(self.clone().do_update());
let runtime_handle = self.inner.context.runtime_handle.clone();
let executor = self.inner.context.executor.clone();
let interval_fut = async move {
while interval.next().await.is_some() {
@@ -468,7 +468,7 @@ impl<T: SlotClock + 'static, E: EthSpec> DutiesService<T, E> {
}
};
runtime_handle.spawn(interval_fut, "duties_service");
executor.spawn(interval_fut, "duties_service");
Ok(())
}

View File

@@ -117,11 +117,11 @@ impl<T: SlotClock + 'static, E: EthSpec> ForkService<T, E> {
// Run an immediate update before starting the updater service.
self.inner
.context
.runtime_handle
.executor
.runtime_handle()
.spawn(self.clone().do_update());
let runtime_handle = self.inner.context.runtime_handle.clone();
let executor = self.inner.context.executor.clone();
let interval_fut = async move {
while interval.next().await.is_some() {
@@ -129,7 +129,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ForkService<T, E> {
}
};
runtime_handle.spawn(interval_fut, "fork_service");
executor.spawn(interval_fut, "fork_service");
Ok(())
}

View File

@@ -8,7 +8,7 @@ use types::EthSpec;
/// Spawns a notifier service which periodically logs information about the node.
pub fn spawn_notifier<T: EthSpec>(client: &ProductionValidatorClient<T>) -> Result<(), String> {
let context = client.context.service_context("notifier".into());
let runtime_handle = context.runtime_handle.clone();
let executor = context.executor.clone();
let duties_service = client.duties_service.clone();
let allow_unsynced_beacon_node = client.config.allow_unsynced_beacon_node;
@@ -81,6 +81,6 @@ pub fn spawn_notifier<T: EthSpec>(client: &ProductionValidatorClient<T>) -> Resu
}
};
runtime_handle.spawn(interval_fut, "validator_notifier");
executor.spawn(interval_fut, "validator_notifier");
Ok(())
}