mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 08:52:54 +00:00
Fix compile error, add comments
This commit is contained in:
@@ -108,13 +108,12 @@ fn new_validator_client<E: EthSpec>(
|
|||||||
) -> LocalValidatorClient<E> {
|
) -> LocalValidatorClient<E> {
|
||||||
let mut config = base_config;
|
let mut config = base_config;
|
||||||
|
|
||||||
let (grpc_endpoint, grpc_port) = beacon_node
|
let socket_addr = beacon_node
|
||||||
.client
|
.client
|
||||||
.grpc_listen_addr()
|
.http_listen_addr()
|
||||||
.expect("Must have gRPC started");
|
.expect("Must have http started");
|
||||||
|
|
||||||
config.server = grpc_endpoint;
|
config.http_server = format!("http://{}:{}", socket_addr.ip(), socket_addr.port());
|
||||||
config.server_grpc_port = grpc_port;
|
|
||||||
|
|
||||||
LocalValidatorClient::production_with_insecure_keypairs(context, config, keypair_indices)
|
LocalValidatorClient::production_with_insecure_keypairs(context, config, keypair_indices)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ const PRUNE_DEPTH: u64 = 4;
|
|||||||
|
|
||||||
type BaseHashMap = HashMap<PublicKey, HashMap<Epoch, ValidatorDuty>>;
|
type BaseHashMap = HashMap<PublicKey, HashMap<Epoch, ValidatorDuty>>;
|
||||||
|
|
||||||
|
/// The outcome of inserting some `ValidatorDuty` into the `DutiesStore`.
|
||||||
enum InsertOutcome {
|
enum InsertOutcome {
|
||||||
/// The duties were previously unknown and have been stored.
|
/// The duties were previously unknown and have been stored.
|
||||||
New,
|
New,
|
||||||
@@ -92,8 +93,6 @@ impl DutiesStore {
|
|||||||
"Store is exclusively locked and this path is guarded to ensure the key exists.",
|
"Store is exclusively locked and this path is guarded to ensure the key exists.",
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: validate that the slots in the duties are all in the given epoch.
|
|
||||||
|
|
||||||
if validator_map.contains_key(&epoch) {
|
if validator_map.contains_key(&epoch) {
|
||||||
let known_duties = validator_map.get_mut(&epoch).expect(
|
let known_duties = validator_map.get_mut(&epoch).expect(
|
||||||
"Validator map is exclusively mutable and this path is guarded to ensure the key exists.",
|
"Validator map is exclusively mutable and this path is guarded to ensure the key exists.",
|
||||||
@@ -190,6 +189,7 @@ impl<T: SlotClock + 'static, E: EthSpec> DutiesServiceBuilder<T, E> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Helper to minimise `Arc` usage.
|
||||||
pub struct Inner<T, E: EthSpec> {
|
pub struct Inner<T, E: EthSpec> {
|
||||||
store: Arc<DutiesStore>,
|
store: Arc<DutiesStore>,
|
||||||
validator_store: ValidatorStore<T, E>,
|
validator_store: ValidatorStore<T, E>,
|
||||||
@@ -198,6 +198,10 @@ pub struct Inner<T, E: EthSpec> {
|
|||||||
context: RuntimeContext<E>,
|
context: RuntimeContext<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Maintains a store of the duties for all voting validators in the `validator_store`.
|
||||||
|
///
|
||||||
|
/// Polls the beacon node at the start of each epoch, collecting duties for the current and next
|
||||||
|
/// epoch.
|
||||||
pub struct DutiesService<T, E: EthSpec> {
|
pub struct DutiesService<T, E: EthSpec> {
|
||||||
inner: Arc<Inner<T, E>>,
|
inner: Arc<Inner<T, E>>,
|
||||||
}
|
}
|
||||||
@@ -234,6 +238,7 @@ impl<T: SlotClock + 'static, E: EthSpec> DutiesService<T, E> {
|
|||||||
self.store.attesters(slot, E::slots_per_epoch())
|
self.store.attesters(slot, E::slots_per_epoch())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Start the service that periodically polls the beacon node for validator duties.
|
||||||
pub fn start_update_service(&self, spec: &ChainSpec) -> Result<Signal, String> {
|
pub fn start_update_service(&self, spec: &ChainSpec) -> Result<Signal, String> {
|
||||||
let log = self.context.log.clone();
|
let log = self.context.log.clone();
|
||||||
|
|
||||||
@@ -279,6 +284,7 @@ impl<T: SlotClock + 'static, E: EthSpec> DutiesService<T, E> {
|
|||||||
Ok(exit_signal)
|
Ok(exit_signal)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Attempt to download the duties of all managed validators for this epoch and the next.
|
||||||
fn do_update(&self) -> impl Future<Item = (), Error = ()> {
|
fn do_update(&self) -> impl Future<Item = (), Error = ()> {
|
||||||
let service_1 = self.clone();
|
let service_1 = self.clone();
|
||||||
let service_2 = self.clone();
|
let service_2 = self.clone();
|
||||||
@@ -334,6 +340,7 @@ impl<T: SlotClock + 'static, E: EthSpec> DutiesService<T, E> {
|
|||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Attempt to download the duties of all managed validators for the given `epoch`.
|
||||||
fn update_epoch(self, epoch: Epoch) -> impl Future<Item = (), Error = String> {
|
fn update_epoch(self, epoch: Epoch) -> impl Future<Item = (), Error = String> {
|
||||||
let service_1 = self.clone();
|
let service_1 = self.clone();
|
||||||
let service_2 = self.clone();
|
let service_2 = self.clone();
|
||||||
|
|||||||
Reference in New Issue
Block a user