mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 12:47:05 +00:00
add HTTP API to retrieve validator IL duties
This commit is contained in:
@@ -812,7 +812,7 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
/// Returns the inclusion list committee for the given `slot` in the current or next epoch.
|
||||
///
|
||||
/// Spec v0.12.1
|
||||
pub fn get_inclusion_list_commitee(
|
||||
pub fn get_inclusion_list_committee(
|
||||
&self,
|
||||
slot: Slot,
|
||||
spec: &ChainSpec,
|
||||
@@ -1721,6 +1721,21 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
Ok(cache.get_attestation_duties(validator_index))
|
||||
}
|
||||
|
||||
pub fn get_inclusion_list_duties(
|
||||
&self,
|
||||
validator_index: usize,
|
||||
epoch: Epoch,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<Option<InclusionListDuty>, Error> {
|
||||
for slot in epoch.slot_iter(E::slots_per_epoch()) {
|
||||
let committee = self.get_inclusion_list_committee(slot, spec)?;
|
||||
if committee.contains(&validator_index) {
|
||||
return Ok(Some(InclusionListDuty { slot }));
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
/// Compute the total active balance cache from scratch.
|
||||
///
|
||||
/// This method should rarely be invoked because single-pass epoch processing keeps the total
|
||||
|
||||
8
consensus/types/src/inclusion_list_duty.rs
Normal file
8
consensus/types/src/inclusion_list_duty.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use crate::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(arbitrary::Arbitrary, Debug, PartialEq, Clone, Copy, Default, Serialize, Deserialize)]
|
||||
pub struct InclusionListDuty {
|
||||
/// The slot during which the validator must produce an inclusion list.
|
||||
pub slot: Slot,
|
||||
}
|
||||
@@ -49,6 +49,7 @@ pub mod graffiti;
|
||||
pub mod historical_batch;
|
||||
pub mod historical_summary;
|
||||
pub mod inclusion_list;
|
||||
pub mod inclusion_list_duty;
|
||||
pub mod indexed_attestation;
|
||||
pub mod light_client_bootstrap;
|
||||
pub mod light_client_finality_update;
|
||||
@@ -180,6 +181,7 @@ pub use crate::fork_versioned_response::{ForkVersionDeserialize, ForkVersionedRe
|
||||
pub use crate::graffiti::{Graffiti, GRAFFITI_BYTES_LEN};
|
||||
pub use crate::historical_batch::HistoricalBatch;
|
||||
pub use crate::inclusion_list::{InclusionList, SignedInclusionList};
|
||||
pub use crate::inclusion_list_duty::InclusionListDuty;
|
||||
pub use crate::indexed_attestation::{
|
||||
IndexedAttestation, IndexedAttestationBase, IndexedAttestationElectra, IndexedAttestationRef,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user