feat: add leaves() iterator to SimpleSmt

This commit is contained in:
Bobbin Threadbare
2023-05-09 18:46:06 -07:00
parent 13aeda5a27
commit 629494b601
4 changed files with 57 additions and 44 deletions

View File

@@ -182,6 +182,14 @@ impl SimpleSmt {
self.get_path(index)
}
// ITERATORS
// --------------------------------------------------------------------------------------------
/// Returns an iterator over the leaves of this [SimpleSmt].
pub fn leaves(&self) -> impl Iterator<Item = (u64, &Word)> {
self.leaves.iter().map(|(i, w)| (*i, w))
}
/// Returns an iterator over the inner nodes of this Merkle tree.
pub fn inner_nodes(&self) -> impl Iterator<Item = InnerNodeInfo> + '_ {
self.branches.values().map(|e| InnerNodeInfo {