Add progress on state_processing fixed-len update

This commit is contained in:
Paul Hauner
2019-05-08 15:36:02 +10:00
parent 7a67d34293
commit 8cefd20e9d
29 changed files with 275 additions and 268 deletions

View File

@@ -3,8 +3,8 @@ use types::{BeaconStateError as Error, *};
/// Exit the validator of the given `index`.
///
/// Spec v0.5.1
pub fn exit_validator(
state: &mut BeaconState,
pub fn exit_validator<T: BeaconStateTypes>(
state: &mut BeaconState<T>,
validator_index: usize,
spec: &ChainSpec,
) -> Result<(), Error> {

View File

@@ -4,8 +4,8 @@ use types::{BeaconStateError as Error, *};
/// Slash the validator with index ``index``.
///
/// Spec v0.5.1
pub fn slash_validator(
state: &mut BeaconState,
pub fn slash_validator<T: BeaconStateTypes>(
state: &mut BeaconState<T>,
validator_index: usize,
spec: &ChainSpec,
) -> Result<(), Error> {
@@ -36,8 +36,7 @@ pub fn slash_validator(
state.set_slashed_balance(
current_epoch,
state.get_slashed_balance(current_epoch, spec)? + effective_balance,
spec,
state.get_slashed_balance(current_epoch)? + effective_balance,
)?;
let whistleblower_index =
@@ -56,7 +55,7 @@ pub fn slash_validator(
state.validator_registry[validator_index].slashed = true;
state.validator_registry[validator_index].withdrawable_epoch =
current_epoch + Epoch::from(spec.latest_slashed_exit_length);
current_epoch + Epoch::from(T::LatestSlashedExitLength::to_usize());
Ok(())
}