mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 04:31:51 +00:00
state_processing: get_attesting_indices in common
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
use crate::common::verify_bitfield_length;
|
||||
use types::*;
|
||||
|
||||
/// Returns validator indices which participated in the attestation.
|
||||
///
|
||||
/// Spec v0.6.1
|
||||
pub fn get_attesting_indices_unsorted<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
attestation_data: &AttestationData,
|
||||
bitfield: &Bitfield,
|
||||
) -> Result<Vec<usize>, BeaconStateError> {
|
||||
let target_relative_epoch =
|
||||
RelativeEpoch::from_epoch(state.current_epoch(), attestation_data.target_epoch)?;
|
||||
|
||||
let committee =
|
||||
state.get_crosslink_committee_for_shard(attestation_data.shard, target_relative_epoch)?;
|
||||
|
||||
if !verify_bitfield_length(&bitfield, committee.committee.len()) {
|
||||
return Err(BeaconStateError::InvalidBitfield);
|
||||
}
|
||||
|
||||
Ok(committee
|
||||
.committee
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, validator_index)| match bitfield.get(i) {
|
||||
Ok(true) => Some(*validator_index),
|
||||
_ => None,
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::get_attesting_indices::get_attesting_indices_unsorted;
|
||||
use super::WinningRootHashSet;
|
||||
use crate::common::get_attesting_indices_unsorted;
|
||||
use types::*;
|
||||
|
||||
/// Sets the boolean `var` on `self` to be true if it is true on `other`. Otherwise leaves `self`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::get_attesting_indices::get_attesting_indices_unsorted;
|
||||
use crate::common::get_attesting_indices_unsorted;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use tree_hash::TreeHash;
|
||||
use types::*;
|
||||
|
||||
Reference in New Issue
Block a user