diff --git a/beacon_chain/types/src/validator_record.rs b/beacon_chain/types/src/validator_record.rs index e63e3ea2c..df0ce4d4c 100644 --- a/beacon_chain/types/src/validator_record.rs +++ b/beacon_chain/types/src/validator_record.rs @@ -21,6 +21,7 @@ impl From for DecodeError { } } +/// Handles the serialization logic for the `status_flags` field of the `ValidatorRecord`. fn status_flag_to_byte(flag: Option) -> u8 { if let Some(flag) = flag { match flag { @@ -32,6 +33,7 @@ fn status_flag_to_byte(flag: Option) -> u8 { } } +/// Handles the deserialization logic for the `status_flags` field of the `ValidatorRecord`. fn status_flag_from_byte(flag: u8) -> Result, StatusFlagsDecodeError> { match flag { 0 => Ok(None), @@ -59,12 +61,14 @@ pub struct ValidatorRecord { } impl ValidatorRecord { + /// This predicate indicates if the validator represented by this record is considered "active" at `slot`. pub fn is_active_at(&self, slot: u64) -> bool { self.activation_slot <= slot && slot < self.exit_slot } } impl Default for ValidatorRecord { + /// Yields a "default" `ValidatorRecord`. Primarily used for testing. fn default() -> Self { Self { pubkey: PublicKey::default(), diff --git a/beacon_chain/types/src/validator_registry.rs b/beacon_chain/types/src/validator_registry.rs index 1171f7acf..abb2e6b3f 100644 --- a/beacon_chain/types/src/validator_registry.rs +++ b/beacon_chain/types/src/validator_registry.rs @@ -2,6 +2,7 @@ /// For now, we avoid defining a newtype and just have flat functions here. use super::validator_record::*; +/// Given an indexed sequence of `validators`, return the indices corresponding to validators that are active at `slot`. pub fn get_active_validator_indices(validators: &[ValidatorRecord], slot: u64) -> Vec { validators .iter()