Skip to main content

apply_balances_iter

Function apply_balances_iter 

Source
pub fn apply_balances_iter<T: ListMutTarget<u64>>(
    target: &mut T,
    delta: &ArchivedBalancesDiff,
) -> Result<(), Error>
Expand description

Applies a balance delta to a mutable balance collection in place.

target must initially contain the base balance snapshot used to generate delta.

Existing balances are reconstructed according to the packed tags in the delta. Changed balances encoded as differences are updated relative to their current base value, while explicit and zero-valued entries replace the corresponding balance directly.

Any balances stored in BalancesDiff::appended_balances are appended to the collection after the common portion has been reconstructed.

This API accepts crate::ListMutTarget so that consensus clients can apply the delta directly to tree-backed or persistent balance collections without first materializing them as a Vec<u64>.

ยงErrors

Returns Error::MalformedDelta if the delta is structurally invalid, contains incomplete payload data, or cannot be safely applied to the supplied target collection.