Apply the value deltas of newly finalized blocks, in finalized (ancestor-first) order.
Moves each inserted value from pending to finalized, drops finalized
references for removed values, and collects anything that becomes unreferenced.
Record a freshly imported, not-yet-finalized block.
Importing the same header twice is a no-op, otherwise the second import
would double-count pending references and pin the values forever.
Record values referenced by the genesis / initial finalized state.
Release the speculative references of a state being discarded.
For a header that was still unfinalized (a dead fork) the returned update
releases its inserted values, which may become collectable. For an already
finalized state the update is empty (check with isEmptyUpdate): its delta
was consumed on finality and its values are accounted for in finalized.
Decides when a content-addressed value can be removed from the values DB.
A value is needed as long as some surviving state references it. Surviving states are the finalized tip plus its unfinalized descendants, so we track:
finalized: how many leaves in the current finalized-tip state reference V, advanced strictly by replaying finalized blocks' deltas (never on prune);pending: how many surviving, not-yet-finalized blocks inserted V (an over-approximation of unfinalized references).A value is removable exactly when both counts reach zero.
This class only makes decisions: every operation reads the current state through
ValueRefsReaderand returns aValueRefsUpdatedescribing what should change. Nothing is written here - the owning backend applies the update with whatever consistency guarantees it can provide.