Skip to main content

apply_validators_iter

Function apply_validators_iter 

Source
pub fn apply_validators_iter<T: ValidatorMutTarget>(
    target: &mut T,
    delta: &ArchivedValidatorsDiff,
) -> Result<(), Error>
Expand description

Applies a validator delta directly to a client’s native validator collection.

The target collection is accessed through ValidatorMutTarget, allowing the caller to mutate validators without converting the entire registry into a contiguous SSZ byte buffer.

For every patch, the corresponding validator is obtained with ValidatorMutTarget::get_mut and the specified field is updated.

Newly appended validators are passed to ValidatorMutTarget::push_from_ssz as complete VALIDATOR_SSZ_SIZE-byte SSZ records.

For a non-slashed validator whose exit_epoch is patched, the withdrawable_epoch is reconstructed automatically as:

exit_epoch + MIN_VALIDATOR_WITHDRAWABILITY_DELAY

For slashed validators, withdrawable_epoch is restored explicitly from the ValidatorField::WithdrawableEpochSlashed patch.

§Errors

Returns Error::MalformedDelta if a patch contains a value with an invalid width for its field.

Returns Error::InvalidDelta if a patch refers to a validator index that does not exist in the target collection.