fn subtrees<C, Range, Node, ChainSubtreeFn, DbSubtreeFn>(
chain: Option<C>,
range: Range,
read_chain: ChainSubtreeFn,
read_disk: DbSubtreeFn,
) -> BTreeMap<NoteCommitmentSubtreeIndex, NoteCommitmentSubtreeData<Node>>where
C: AsRef<Chain>,
Node: PartialEq,
Range: RangeBounds<NoteCommitmentSubtreeIndex> + Clone,
ChainSubtreeFn: FnOnce(&Chain, Range) -> BTreeMap<NoteCommitmentSubtreeIndex, NoteCommitmentSubtreeData<Node>>,
DbSubtreeFn: FnOnce(Range) -> BTreeMap<NoteCommitmentSubtreeIndex, NoteCommitmentSubtreeData<Node>>,
Expand description
Returns a list of NoteCommitmentSubtree
s 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.