mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-19 21:04:41 +00:00
@@ -1,19 +1,15 @@
|
||||
extern crate types;
|
||||
|
||||
use types::{
|
||||
ValidatorRecord,
|
||||
ValidatorStatus,
|
||||
};
|
||||
use types::{ValidatorRecord, ValidatorStatus};
|
||||
|
||||
pub fn validator_is_active(v: &ValidatorRecord) -> bool {
|
||||
v.status == ValidatorStatus::Active as u8
|
||||
}
|
||||
|
||||
/// Returns the indicies of each active validator in a given vec of validators.
|
||||
pub fn active_validator_indices(validators: &[ValidatorRecord])
|
||||
-> Vec<usize>
|
||||
{
|
||||
validators.iter()
|
||||
pub fn active_validator_indices(validators: &[ValidatorRecord]) -> Vec<usize> {
|
||||
validators
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, validator)| {
|
||||
if validator_is_active(&validator) {
|
||||
@@ -21,8 +17,7 @@ pub fn active_validator_indices(validators: &[ValidatorRecord])
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}).collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user