mirror of
https://github.com/vacp2p/pmtree.git
synced 2025-02-19 18:48:13 +00:00
fix: public getter
This commit is contained in:
parent
b3a02216ce
commit
8b38443637
11
src/tree.rs
11
src/tree.rs
@ -136,7 +136,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recalculates `Merkle Tree` from the specified key
|
// Recalculates `Merkle Tree` from the specified key
|
||||||
fn recalculate_from(&mut self, key: usize) -> PmtreeResult<()> {
|
pub fn recalculate_from(&mut self, key: usize) -> PmtreeResult<()> {
|
||||||
let mut depth = self.depth;
|
let mut depth = self.depth;
|
||||||
let mut i = key;
|
let mut i = key;
|
||||||
|
|
||||||
@ -174,6 +174,15 @@ where
|
|||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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))
|
||||||
|
}
|
||||||
|
|
||||||
/// Deletes a leaf at the `key` by setting it to its default value
|
/// Deletes a leaf at the `key` by setting it to its default value
|
||||||
pub fn delete(&mut self, key: usize) -> PmtreeResult<()> {
|
pub fn delete(&mut self, key: usize) -> PmtreeResult<()> {
|
||||||
if key >= self.next_index {
|
if key >= self.next_index {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user