Skip to main content

diff_validators

Function diff_validators 

Source
pub fn diff_validators(base_bytes: &[u8], target_bytes: &[u8]) -> ValidatorsDiff
Expand description

Computes a compact validator delta from two contiguous SSZ byte buffers.

Both buffers must contain zero or more complete validator records, with each record occupying exactly VALIDATOR_SSZ_SIZE bytes.

The resulting ValidatorsDiff contains:

  • field-level patches for validators present in both buffers; and
  • complete SSZ records for validators appended to the target buffer.

The function does not allocate or deserialize individual validator structures while scanning the common portion of the buffers. Fields are read directly from their fixed offsets in the SSZ representation.

§Examples

A delta can be applied to the original buffer to reconstruct the target:

let delta = diff_validators(&base, &target);
apply_validators(&mut base, &delta);

assert_eq!(base, target);