Skip to main content

diff_fifo_queue

Function diff_fifo_queue 

Source
pub fn diff_fifo_queue(
    base_ssz: &[u8],
    target_ssz: &[u8],
    item_ssz_size: usize,
) -> FifoQueueDiff
Expand description

Computes the delta between two serialized FIFO queues.

The queues are expected to contain fixed-size SSZ items.

The resulting delta records:

  • the number of items consumed from the front of the base queue; and
  • the SSZ bytes of items appended to the end of the queue.

If no overlap between the queues can be identified, the encoder assumes the base queue was entirely consumed.

ยงAlgorithm

The encoder identifies the overlap by locating the first item in the target queue within the base queue. This assumes queue items are sufficiently unique that the first match represents the correct continuation of the FIFO sequence.