Skip to main content

diff_eth1_votes

Function diff_eth1_votes 

Source
pub fn diff_eth1_votes(base: &[u8], target: &[u8]) -> Eth1DataVotesDiff
Expand description

Computes a delta between two serialized Eth1 data vote lists.

The target length determines which representation is used:

This function operates directly on serialized SSZ bytes and does not deserialize individual votes.

§Arguments

  • base - Serialized SSZ representation of the current vote list.
  • target - Serialized SSZ representation of the target vote list.

§Returns

A delta that represents the transition from base to target according to the length-based append/reset semantics described above.

§Complexity

O(n), where n is the size of the target buffer, due to copying the resulting delta payload.

§Example

use eth_state_diff::eth1_data_votes::diff_eth1_votes;
use eth_state_diff::types::Eth1DataVotesDiff;

let base = b"AAAA";
let target = b"AAAABBBB";

let delta = diff_eth1_votes(base, target);

assert_eq!(delta, Eth1DataVotesDiff::Append(b"BBBB".to_vec()));