incrementalmerkletree: Add `Frontier::tree_size`
This commit is contained in:
parent
4d797cce13
commit
353db2efa2
|
@ -7,6 +7,9 @@ and this project adheres to Rust's notion of
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- `incrementalmerkletree::Frontier::tree_size`
|
||||||
|
|
||||||
## [0.5.0] - 2023-09-08
|
## [0.5.0] - 2023-09-08
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -225,6 +225,13 @@ impl<H, const DEPTH: u8> Frontier<H, DEPTH> {
|
||||||
size_of::<usize>() + (f.ommers.capacity() + 1) * size_of::<H>()
|
size_of::<usize>() + (f.ommers.capacity() + 1) * size_of::<H>()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the size of the Merkle tree that this frontier corresponds to.
|
||||||
|
pub fn tree_size(&self) -> u64 {
|
||||||
|
self.frontier
|
||||||
|
.as_ref()
|
||||||
|
.map_or(0, |f| u64::from(f.position()) + 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<H: Hashable + Clone, const DEPTH: u8> Frontier<H, DEPTH> {
|
impl<H: Hashable + Clone, const DEPTH: u8> Frontier<H, DEPTH> {
|
||||||
|
|
Loading…
Reference in New Issue