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(
|
pub fn build_subtree(
|
||||||
leaves: Vec<SubtreeLeaf>,
|
leaves: Vec<SubtreeLeaf>,
|
||||||
bottom_depth: u8,
|
bottom_depth: u8,
|
||||||
|
|
|
@ -406,17 +406,19 @@ pub(crate) trait SparseMerkleTree<const DEPTH: u8> {
|
||||||
accumulator
|
accumulator
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds Merkle nodes from a bottom layer of tuples of horizontal indices and their hashes,
|
/// Builds Merkle nodes from a bottom layer of "leaves" -- represented by a horizontal index and
|
||||||
/// sorted by their position.
|
/// 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
|
/// This function will then calculate the inner nodes above each leaf for 8 layers, as well as
|
||||||
/// [`Self::Leaf`].
|
/// the "leaves" for the next 8-deep subtree, so this function can effectively be chained into
|
||||||
|
/// itself.
|
||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
/// With debug assertions on, this function panics under invalid inputs: if `leaves` contains
|
/// 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
|
/// more entries than can fit in a depth-8 subtree, if `leaves` contains leaves belonging to
|
||||||
/// lower in the tree than the specified maximum depth (`DEPTH`), or if `leaves` is not sorted.
|
/// different depth-8 subtrees, if `bottom_depth` is lower in the tree than the specified
|
||||||
// FIXME: more complete docstring.
|
/// maximum depth (`DEPTH`), or if `leaves` is not sorted.
|
||||||
fn build_subtree(
|
fn build_subtree(
|
||||||
mut leaves: Vec<SubtreeLeaf>,
|
mut leaves: Vec<SubtreeLeaf>,
|
||||||
bottom_depth: u8,
|
bottom_depth: u8,
|
||||||
|
|
Loading…
Add table
Reference in a new issue