Refactor `exit_validator`

This commit is contained in:
Hsiao-Wei Wang 2019-02-26 17:07:59 +08:00
parent bdd6868736
commit bcb0b8bf87
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
1 changed files with 4 additions and 3 deletions

View File

@ -1316,12 +1316,13 @@ def exit_validator(state: BeaconState, index: ValidatorIndex) -> None:
Note that this function mutates ``state``. Note that this function mutates ``state``.
""" """
validator = state.validator_registry[index] validator = state.validator_registry[index]
delayed_activation_exit_epoch = get_delayed_activation_exit_epoch(get_current_epoch(state))
# The following updates only occur if not previous exited # The following updates only occur if not previous exited
if validator.exit_epoch <= get_delayed_activation_exit_epoch(get_current_epoch(state)): if validator.exit_epoch <= delayed_activation_exit_epoch:
return return
else:
validator.exit_epoch = get_delayed_activation_exit_epoch(get_current_epoch(state)) validator.exit_epoch = delayed_activation_exit_epoch
``` ```
#### `slash_validator` #### `slash_validator`