mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 19:02:42 +00:00
Split validator into ValidatorMutable
This commit is contained in:
@@ -9,7 +9,7 @@ pub fn initiate_validator_exit<T: EthSpec>(
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
// Return if the validator already initiated exit
|
||||
if state.get_validator(index)?.exit_epoch != spec.far_future_epoch {
|
||||
if state.get_validator(index)?.exit_epoch() != spec.far_future_epoch {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ pub fn initiate_validator_exit<T: EthSpec>(
|
||||
|
||||
// FIXME(sproul): could avoid this second lookup with some clever borrowing
|
||||
let mut validator = state.get_validator_mut(index)?;
|
||||
validator.exit_epoch = exit_queue_epoch;
|
||||
validator.withdrawable_epoch =
|
||||
validator.mutable.exit_epoch = exit_queue_epoch;
|
||||
validator.mutable.withdrawable_epoch =
|
||||
exit_queue_epoch.safe_add(spec.min_validator_withdrawability_delay)?;
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -18,12 +18,12 @@ pub fn slash_validator<T: EthSpec>(
|
||||
initiate_validator_exit(state, slashed_index, spec)?;
|
||||
|
||||
let validator = state.get_validator_mut(slashed_index)?;
|
||||
validator.slashed = true;
|
||||
validator.withdrawable_epoch = cmp::max(
|
||||
validator.withdrawable_epoch,
|
||||
validator.mutable.slashed = true;
|
||||
validator.mutable.withdrawable_epoch = cmp::max(
|
||||
validator.withdrawable_epoch(),
|
||||
epoch.safe_add(T::EpochsPerSlashingsVector::to_u64())?,
|
||||
);
|
||||
let validator_effective_balance = validator.effective_balance;
|
||||
let validator_effective_balance = validator.effective_balance();
|
||||
state.set_slashings(
|
||||
epoch,
|
||||
state
|
||||
|
||||
Reference in New Issue
Block a user