Skip to main content

assign_block_end_retention

Function assign_block_end_retention 

Source
pub fn assign_block_end_retention<H>(
    commitments: &mut [Option<(H, Retention<BlockHeight>)>],
    start_position: Position,
    checkpoint_floor: BlockHeight,
    anchor_retention: Option<&AnchorRetention>,
    missing_checkpoints: &mut Vec<(BlockHeight, Checkpoint)>,
)
Expand description

Sets the retention of each block-end commitment in commitments, the first of which is at start_position.

A block end that keeps its checkpoint under checkpoint_floor and anchor_retention is left as it is. Any other block end gives up its checkpoint, except where an entry of missing_checkpoints lies at its position: the commitment then carries the checkpoint for the lowest such height, and that entry is removed from missing_checkpoints. The commitment and its checkpoint are then inserted together, so the tree keeps the leaf that the remaining entries at that position refer to. A commitment that gives up its checkpoint keeps only its marking: a wallet note’s commitment stays Marked, a referenced commitment stays Reference, and any other commitment becomes Ephemeral.

missing_checkpoints is a batch’s BatchCheckpoints for the pool. A store that builds only part of a batch’s commitments now (and the rest out of band) assigns each part it builds, from that part’s first position; an entry at a position it does not build stays in missing_checkpoints, and update_tree adds it as a checkpoint of the store.