Skip to content

Commit

Permalink
rename get_leaf_at
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer committed Jan 11, 2024
1 parent 8dcb297 commit b574bf6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/merkle/simple_smt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl<const DEPTH: u8> SimpleSmt<DEPTH> {
} else if index.depth() > self.depth() {
Err(MerkleError::DepthTooBig(index.depth() as u64))
} else if index.depth() == self.depth() {
let leaf = self.get_leaf_at(&LeafIndex::<DEPTH>::try_from(index)?);
let leaf = self.get_leaf(&LeafIndex::<DEPTH>::try_from(index)?);

Ok(leaf.into())
} else {
Expand Down Expand Up @@ -318,7 +318,7 @@ impl<const DEPTH: u8> SparseMerkleTree<DEPTH> for SimpleSmt<DEPTH> {
self.leaves.insert(key.value(), value)
}

fn get_leaf_at(&self, key: &LeafIndex<DEPTH>) -> Word {
fn get_leaf(&self, key: &LeafIndex<DEPTH>) -> Word {
// the lookup in empty_hashes could fail only if empty_hashes were not built correctly
// by the constructor as we check the depth of the lookup above.
let leaf_pos = key.value();
Expand Down
2 changes: 1 addition & 1 deletion src/merkle/simple_smt/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ fn test_simplesmt_set_subtree() {
};

assert_eq!(tree.root(), k);
assert_eq!(tree.get_leaf_at(&LeafIndex::<TREE_DEPTH>::new(4).unwrap()), c);
assert_eq!(tree.get_leaf(&LeafIndex::<TREE_DEPTH>::new(4).unwrap()), c);
assert_eq!(tree.get_branch_node(&NodeIndex::new_unchecked(2, 2)).hash(), g);
}

Expand Down
4 changes: 2 additions & 2 deletions src/merkle/smt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub trait SparseMerkleTree<const DEPTH: u8> {
return value;
}

let leaf = self.get_leaf_at(&key);
let leaf = self.get_leaf(&key);
let node_index = {
let leaf_index: LeafIndex<DEPTH> = key.into();
leaf_index.into()
Expand Down Expand Up @@ -123,7 +123,7 @@ pub trait SparseMerkleTree<const DEPTH: u8> {
fn insert_leaf_node(&mut self, key: Self::Key, value: Self::Value) -> Option<Self::Value>;

/// Returns the leaf at the specified index.
fn get_leaf_at(&self, key: &Self::Key) -> Self::Leaf;
fn get_leaf(&self, key: &Self::Key) -> Self::Leaf;

/// Returns the hash of a leaf
fn hash_leaf(leaf: &Self::Leaf) -> RpoDigest;
Expand Down
2 changes: 1 addition & 1 deletion src/merkle/store/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ fn test_recorder() {
let node = merkle_store.get_node(smtree.root(), index_2).unwrap();
assert_eq!(
node,
smtree.get_leaf_at(&LeafIndex::<TREE_DEPTH>::try_from(index_2).unwrap()).into()
smtree.get_leaf(&LeafIndex::<TREE_DEPTH>::try_from(index_2).unwrap()).into()
);

// assert that is doesnt contain nodes that were not recorded
Expand Down

0 comments on commit b574bf6

Please sign in to comment.