Uses the new get_active_validator_indices implementation

This commit is contained in:
Alex Stokes 2019-01-10 14:47:25 -06:00
parent 869f36ffbe
commit 2d1b61522b
No known key found for this signature in database
GPG Key ID: 51CE1721B245C086

View File

@ -2,7 +2,8 @@ use std::cmp::min;
use honey_badger_split::SplitExt;
use spec::ChainSpec;
use types::{ShardCommittee, ValidatorRecord, ValidatorStatus};
use types::validator_registry::get_active_validator_indices;
use types::{ShardCommittee, ValidatorRecord};
use vec_shuffle::{shuffle, ShuffleErr};
type DelegatedCycle = Vec<Vec<ShardCommittee>>;
@ -24,17 +25,7 @@ pub fn shard_and_committees_for_cycle(
spec: &ChainSpec,
) -> Result<DelegatedCycle, ValidatorAssignmentError> {
let shuffled_validator_indices = {
let validator_indices = validators
.iter()
.enumerate()
.filter_map(|(i, validator)| {
if validator.status_is(ValidatorStatus::Active) {
Some(i)
} else {
None
}
})
.collect();
let validator_indices = get_active_validator_indices(validators, 0);
shuffle(seed, validator_indices)?
};
let shard_indices: Vec<usize> = (0_usize..spec.shard_count as usize).into_iter().collect();