feat: added handling of bottom tier to TieredSmt

This commit is contained in:
Bobbin Threadbare
2023-05-14 02:29:42 -07:00
parent 51ce07cc34
commit b768eade4d
7 changed files with 654 additions and 217 deletions

View File

@@ -73,7 +73,7 @@ impl MerklePathSet {
let path_key = index.value() - parity;
self.paths
.get(&path_key)
.ok_or(MerkleError::NodeNotInSet(path_key))
.ok_or(MerkleError::NodeNotInSet(index))
.map(|path| path[parity as usize])
}
@@ -104,11 +104,8 @@ impl MerklePathSet {
let parity = index.value() & 1;
let path_key = index.value() - parity;
let mut path = self
.paths
.get(&path_key)
.cloned()
.ok_or(MerkleError::NodeNotInSet(index.value()))?;
let mut path =
self.paths.get(&path_key).cloned().ok_or(MerkleError::NodeNotInSet(index))?;
path.remove(parity as usize);
Ok(path)
}
@@ -200,7 +197,7 @@ impl MerklePathSet {
let path_key = index.value() - parity;
let path = match self.paths.get_mut(&path_key) {
Some(path) => path,
None => return Err(MerkleError::NodeNotInSet(base_index_value)),
None => return Err(MerkleError::NodeNotInSet(index)),
};
// Fill old_hashes vector -----------------------------------------------------------------