pub fn apply_attestations(base: &mut Vec<u8>, delta: &ArchivedAttestationsDiff)Expand description
Applies an attestation delta to a serialized SSZ list in place.
AttestationsDiff::Unchanged leaves the base buffer untouched.
AttestationsDiff::Append appends the serialized bytes stored in the
delta to the existing buffer.
AttestationsDiff::FullReplacement clears the existing buffer and
replaces it with the serialized target bytes.
§Complexity
AttestationsDiff::Unchanged: O(1).AttestationsDiff::Append: O(k), where k is the number of appended bytes.AttestationsDiff::FullReplacement: O(n), where n is the size of the replacement list.
§Example
let mut base = b"AAAA".to_vec();
let delta = diff_attestations(&base, b"AAAABBBB");
match delta {
AttestationsDiff::Unchanged => {}
AttestationsDiff::Append(bytes) => base.extend_from_slice(&bytes),
AttestationsDiff::FullReplacement(bytes) => {
base.clear();
base.extend_from_slice(&bytes);
}
}
assert_eq!(base, b"AAAABBBB");