Skip to main content

diff_participation_iter

Function diff_participation_iter 

Source
pub fn diff_participation_iter<I1, I2>(
    base: I1,
    target: I2,
) -> ParticipationDiff
where I1: ExactSizeIterator<Item = u8>, I2: ExactSizeIterator<Item = u8>,
Expand description

Computes a compact sparse delta between two participation flag iterators.

This API is intended for consensus clients whose participation flags are stored in tree-backed or otherwise non-contiguous structures. The caller can expose the values through ExactSizeIterators without first materializing the complete vectors as contiguous buffers.

The iterators are consumed during diff generation.

Unlike diff_participation, this function always returns ParticipationDiff::Sparse. It does not perform the all-zero specialization because the iterator is consumed while determining the changed entries.

Values remaining in target after the common portion are treated as newly appended participation flags and are stored in the delta’s extension field.

§Complexity

O(n) time and O(m + e) additional space, where n is the size of the common portion, m is the number of modified entries, and e is the number of appended target entries.