mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-25 21:17:17 +00:00
Add ability to get shuffling from BeaconState
This commit is contained in:
parent
29792c56d5
commit
c214bec344
@ -343,6 +343,17 @@ impl<T: EthSpec> BeaconState<T> {
|
||||
get_active_validator_indices(&self.validator_registry, epoch)
|
||||
}
|
||||
|
||||
/// Return the cached active validator indices at some epoch.
|
||||
///
|
||||
/// Note: the indices are shuffled (i.e., not in ascending order).
|
||||
///
|
||||
/// Returns an error if that epoch is not cached, or the cache is not initialized.
|
||||
pub fn get_shuffling(&self, relative_epoch: RelativeEpoch) -> Result<&[usize], Error> {
|
||||
let cache = self.cache(relative_epoch)?;
|
||||
|
||||
Ok(cache.shuffling())
|
||||
}
|
||||
|
||||
/// Returns the crosslink committees for some slot.
|
||||
///
|
||||
/// Note: Utilizes the cache and will fail if the appropriate cache is not initialized.
|
||||
|
@ -114,6 +114,15 @@ impl CommitteeCache {
|
||||
&self.shuffling
|
||||
}
|
||||
|
||||
/// Returns the shuffled list of active validator indices for the initialized epoch.
|
||||
///
|
||||
/// Always returns `&[]` for a non-initialized epoch.
|
||||
///
|
||||
/// Spec v0.6.1
|
||||
pub fn shuffling(&self) -> &[usize] {
|
||||
&self.shuffling
|
||||
}
|
||||
|
||||
/// Return `Some(CrosslinkCommittee)` if the given shard has a committee during the given
|
||||
/// `epoch`.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user