Skip to main content

apply_validators_iter

Function apply_validators_iter 

Source
pub fn apply_validators_iter<T: ValidatorMutTarget>(
    target: &mut T,
    delta: &ArchivedValidatorsDiff,
)
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.

§Missing validators

If ValidatorMutTarget::get_mut returns None for a patch index, that patch is skipped.

Implementations should therefore ensure that the target collection has the same base validator ordering and length expected by the delta.

§Panics

Panics if a patch contains a value with an invalid width for its field.