Function zebra_state::service::read::tree::subtrees

source ·
fn subtrees<C, Range, Node, ChainSubtreeFn, DbSubtreeFn>(
    chain: Option<C>,
    range: Range,
    read_chain: ChainSubtreeFn,
    read_disk: DbSubtreeFn,
) -> BTreeMap<NoteCommitmentSubtreeIndex, NoteCommitmentSubtreeData<Node>>
Expand description

Returns a list of NoteCommitmentSubtrees in the provided range.

If there is no subtree at the first index in the range, the returned list is empty. Otherwise, subtrees are continuous up to the finalized tip.

Accepts a chain from the non-finalized state, a range of subtree indexes to retrieve, a read_chain function for retrieving the range of subtrees from chain, and a read_disk function for retrieving the range from ZebraDb.

Returns a consistent set of subtrees for the supplied chain fork and database. Avoids reading the database if the subtrees are present in memory.

§Correctness

APIs that return single subtrees can’t be used for read_chain and read_disk, because they can create an inconsistent list of subtrees after concurrent non-finalized and finalized updates.