mirror of https://github.com/vacp2p/pmtree.git
fix: review
This commit is contained in:
parent
8b38443637
commit
bf27d4273b
20
src/tree.rs
20
src/tree.rs
|
@ -136,7 +136,7 @@ where
|
|||
}
|
||||
|
||||
// Recalculates `Merkle Tree` from the specified key
|
||||
pub fn recalculate_from(&mut self, key: usize) -> PmtreeResult<()> {
|
||||
fn recalculate_from(&mut self, key: usize) -> PmtreeResult<()> {
|
||||
let mut depth = self.depth;
|
||||
let mut i = key;
|
||||
|
||||
|
@ -174,15 +174,6 @@ where
|
|||
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
|
||||
pub fn delete(&mut self, key: usize) -> PmtreeResult<()> {
|
||||
if key >= self.next_index {
|
||||
|
@ -353,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
|
||||
|
|
Loading…
Reference in New Issue