Remove state.get_crosslink_committee fn

Replaced by state.get_crosslink_committee_for_shard
This commit is contained in:
Paul Hauner
2019-05-19 17:08:09 +10:00
parent ea96d24420
commit 9264ec1aa9
5 changed files with 18 additions and 31 deletions

View File

@@ -163,7 +163,8 @@ pub fn process_crosslinks<T: EthSpec>(
let epoch = relative_epoch.into_epoch(state.current_epoch());
for offset in 0..state.get_epoch_committee_count(relative_epoch)? {
let shard = (state.get_epoch_start_shard(relative_epoch)? + offset) % spec.shard_count;
let crosslink_committee = state.get_crosslink_committee(epoch, shard, spec)?;
let crosslink_committee =
state.get_crosslink_committee_for_shard(shard, relative_epoch)?;
let winning_root = winning_root(state, shard, epoch, spec)?;

View File

@@ -8,13 +8,12 @@ pub fn get_attesting_indices_unsorted<T: EthSpec>(
state: &BeaconState<T>,
attestation_data: &AttestationData,
bitfield: &Bitfield,
spec: &ChainSpec,
) -> Result<Vec<usize>, BeaconStateError> {
let committee = state.get_crosslink_committee(
attestation_data.target_epoch,
attestation_data.shard,
spec,
)?;
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);

View File

@@ -214,7 +214,7 @@ impl ValidatorStatuses {
.chain(state.current_epoch_attestations.iter())
{
let attesting_indices =
get_attesting_indices_unsorted(state, &a.data, &a.aggregation_bitfield, spec)?;
get_attesting_indices_unsorted(state, &a.data, &a.aggregation_bitfield)?;
let mut status = ValidatorStatus::default();

View File

@@ -77,7 +77,7 @@ pub fn winning_root<T: EthSpec>(
let mut winning_root = None;
for (crosslink, attestations) in candidate_crosslink_map {
let attesting_validator_indices =
get_unslashed_attesting_indices_unsorted(state, &attestations, spec)?;
get_unslashed_attesting_indices_unsorted(state, &attestations)?;
let total_attesting_balance =
state.get_total_balance(&attesting_validator_indices, spec)?;
@@ -102,7 +102,6 @@ pub fn winning_root<T: EthSpec>(
pub fn get_unslashed_attesting_indices_unsorted<T: EthSpec>(
state: &BeaconState<T>,
attestations: &[&PendingAttestation],
spec: &ChainSpec,
) -> Result<Vec<usize>, BeaconStateError> {
let mut output = HashSet::new();
for a in attestations {
@@ -110,7 +109,6 @@ pub fn get_unslashed_attesting_indices_unsorted<T: EthSpec>(
state,
&a.data,
&a.aggregation_bitfield,
spec,
)?);
}
Ok(output