Move active_validators into own crate

This commit is contained in:
Paul Hauner
2018-10-23 23:42:01 +02:00
parent a34266de0a
commit da25a66196
6 changed files with 21 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
[dependencies]
active-validators = { path = "../utils/active-validators" }
honey-badger-split = { path = "../utils/honey-badger-split" }
types = { path = "../types" }
vec_shuffle = { path = "../utils/vec_shuffle" }

View File

@@ -1,19 +0,0 @@
use types::{
ValidatorRecord,
ValidatorStatus,
};
/// Returns the indicies of each active validator in a given vec of validators.
pub fn active_validator_indices(validators: &[ValidatorRecord])
-> Vec<usize>
{
validators.iter()
.enumerate()
.filter_map(|(i, validator)| {
match validator.status {
x if x == ValidatorStatus::Active as u8 => Some(i),
_ => None
}
})
.collect()
}

View File

@@ -1,8 +1,8 @@
extern crate active_validators;
extern crate honey_badger_split;
extern crate vec_shuffle;
extern crate types;
mod active_validator_indices;
mod shuffle;
pub use shuffle::{

View File

@@ -1,5 +1,6 @@
use std::cmp::min;
use active_validators::active_validator_indices;
use honey_badger_split::SplitExt;
use vec_shuffle::{
shuffle,
@@ -11,7 +12,6 @@ use types::{
ChainConfig,
};
use super::active_validator_indices::active_validator_indices;
type DelegatedCycle = Vec<Vec<ShardAndCommittee>>;