improve docs for build_subtree()
This commit is contained in:
parent
76eb7f6d01
commit
8fa9ad5b48
2 changed files with 22 additions and 7 deletions
|
@ -238,6 +238,19 @@ impl Smt {
|
|||
}
|
||||
}
|
||||
|
||||
/// Builds Merkle nodes from a bottom layer of "leaves" -- represented by a horizontal index and
|
||||
/// the hash of the leaf at that index. `leaves` *must* be sorted by horizontal index, and
|
||||
/// `leaves` must not contain more than one depth-8 subtree's worth of leaves.
|
||||
///
|
||||
/// This function will then calculate the inner nodes above each leaf for 8 layers, as well as
|
||||
/// the "leaves" for the next 8-deep subtree, so this function can effectively be chained into
|
||||
/// itself.
|
||||
///
|
||||
/// # Panics
|
||||
/// With debug assertions on, this function panics under invalid inputs: if `leaves` contains
|
||||
/// more entries than can fit in a depth-8 subtree, if `leaves` contains leaves belonging to
|
||||
/// different depth-8 subtrees, if `bottom_depth` is lower in the tree than the specified
|
||||
/// maximum depth (`DEPTH`), or if `leaves` is not sorted.
|
||||
pub fn build_subtree(
|
||||
leaves: Vec<SubtreeLeaf>,
|
||||
bottom_depth: u8,
|
||||
|
|
|
@ -406,17 +406,19 @@ pub(crate) trait SparseMerkleTree<const DEPTH: u8> {
|
|||
accumulator
|
||||
}
|
||||
|
||||
/// Builds Merkle nodes from a bottom layer of tuples of horizontal indices and their hashes,
|
||||
/// sorted by their position.
|
||||
/// Builds Merkle nodes from a bottom layer of "leaves" -- represented by a horizontal index and
|
||||
/// the hash of the leaf at that index. `leaves` *must* be sorted by horizontal index, and
|
||||
/// `leaves` must not contain more than one depth-8 subtree's worth of leaves.
|
||||
///
|
||||
/// The leaves are 'conceptual' leaves, simply being entities at the bottom of some subtree, not
|
||||
/// [`Self::Leaf`].
|
||||
/// This function will then calculate the inner nodes above each leaf for 8 layers, as well as
|
||||
/// the "leaves" for the next 8-deep subtree, so this function can effectively be chained into
|
||||
/// itself.
|
||||
///
|
||||
/// # Panics
|
||||
/// With debug assertions on, this function panics under invalid inputs: if `leaves` contains
|
||||
/// more entries than can fit in a depth-8 subtree (more than 256), if `bottom_depth` is
|
||||
/// lower in the tree than the specified maximum depth (`DEPTH`), or if `leaves` is not sorted.
|
||||
// FIXME: more complete docstring.
|
||||
/// more entries than can fit in a depth-8 subtree, if `leaves` contains leaves belonging to
|
||||
/// different depth-8 subtrees, if `bottom_depth` is lower in the tree than the specified
|
||||
/// maximum depth (`DEPTH`), or if `leaves` is not sorted.
|
||||
fn build_subtree(
|
||||
mut leaves: Vec<SubtreeLeaf>,
|
||||
bottom_depth: u8,
|
||||
|
|
Loading…
Add table
Reference in a new issue