pub fn update_tree<S, const DEPTH: u8, const SHARD_HEIGHT: u8>(
protocol: &'static str,
frontier: &Frontier<S::H, DEPTH>,
frontier_height: BlockHeight,
checkpoint_floor: BlockHeight,
tree: &mut ShardTree<S, DEPTH, SHARD_HEIGHT>,
anchor_retention: Option<&AnchorRetention>,
subtrees: impl Iterator<Item = (LocatedPrunableTree<S::H>, BTreeMap<BlockHeight, Position>)>,
missing_checkpoints: impl Iterator<Item = (BlockHeight, Checkpoint)>,
) -> Result<(), ShardTreeError<S::Error>>Expand description
Updates the given note commitment tree with all newly read note commitments starting
at the block frontier_height + 1.
missing_checkpoints supplies the checkpoints that no commitment in subtrees creates. Each
is added whatever its height. The frontier’s leaf is inserted as follows:
- If
frontier_heightis abovecheckpoint_floor, oranchor_retentionretains it, the frontier is checkpointed atfrontier_height. - Otherwise, if an entry of
missing_checkpointslies at the frontier’s position, the frontier carries the checkpoint for the lowest such entry, so the tree keeps the leaf that the other entries at that position refer to. - Otherwise the frontier’s leaf is kept as a reference only.
If anchor_retention is Some, every checkpoint the policy
retains is kept as a durable anchor.
This is generic over the [ShardStore] backing the tree, so stores that maintain their note
commitment trees by other means (for example, accumulating updates in memory and flushing
them in bulk) can reuse the exact tree-update logic that put_blocks applies.