pub fn diff_eth1_votes(base: &[u8], target: &[u8]) -> Eth1DataVotesDiffExpand description
Computes a delta between two serialized Eth1 data vote lists.
The target length determines which representation is used:
- If
targetis at least as long asbase, the bytes beyond the base length are stored asEth1DataVotesDiff::Append. - If
targetis shorter thanbase, the vote list is treated as having been reset and the complete target list is stored inEth1DataVotesDiff::ResetAndAppend.
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()));