Move state trans fns into state_processing

This commit is contained in:
Paul Hauner
2019-03-18 21:34:42 +11:00
parent 7503f31ddc
commit 1028acf3f1
17 changed files with 741 additions and 669 deletions

View File

@@ -0,0 +1,22 @@
use types::{BeaconStateError as Error, *};
/// Exit the validator of the given `index`.
///
/// Spec v0.5.0
pub fn exit_validator(
state: &mut BeaconState,
validator_index: usize,
spec: &ChainSpec,
) -> Result<(), Error> {
if validator_index >= state.validator_registry.len() {
return Err(Error::UnknownValidator);
}
let delayed_epoch = state.get_delayed_activation_exit_epoch(state.current_epoch(spec), spec);
if state.validator_registry[validator_index].exit_epoch > delayed_epoch {
state.validator_registry[validator_index].exit_epoch = delayed_epoch;
}
Ok(())
}