Merge pull request #11 from Rate-Limiting-Nullifier/fix-add-public-get

fix: add public getters
This commit is contained in:
Magamedrasul Ibragimov 2023-05-10 16:24:24 +04:00 committed by GitHub
commit a312a50bff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -344,6 +344,15 @@ where
self.root() == expected_root
}
// Returns the leaf by the key
pub fn get(&self, key: usize) -> PmtreeResult<H::Fr> {
if key >= self.capacity() {
return Err(PmtreeErrorKind::TreeError(TreeErrorKind::IndexOutOfBounds));
}
self.get_elem(Key(self.depth, key))
}
/// Returns the root of the tree
pub fn root(&self) -> H::Fr {
self.root