Skip to main content

apply_attestations

Function apply_attestations 

Source
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

§Example


let mut base = b"AAAA".to_vec();
let delta = diff_attestations(&base, b"AAAABBBB");

let bytes = rkyv::to_bytes::<rkyv::rancor::Error>(&delta).unwrap();
let archived = unsafe { rkyv::access_unchecked::<ArchivedAttestationsDiff>(&bytes) };

apply_attestations(&mut base, archived);

assert_eq!(base, b"AAAABBBB");