Compare commits
3 commits
1662a0a8da
...
1795ef4ba3
Author | SHA1 | Date | |
---|---|---|---|
1795ef4ba3 | |||
00e2be79a4 | |||
52ab7bca97 |
3 changed files with 4 additions and 1 deletions
|
@ -336,7 +336,7 @@ impl SparseMerkleTree<SMT_DEPTH> for Smt {
|
||||||
|
|
||||||
let (before_pos, rest) = pairs.split_at(pos);
|
let (before_pos, rest) = pairs.split_at(pos);
|
||||||
let with_pos_removed = rest.iter().copied().skip(1);
|
let with_pos_removed = rest.iter().copied().skip(1);
|
||||||
let middle = iter::once(new_pair).filter(|_| !is_removal);
|
let middle = if !is_removal { Some(new_pair) } else { None };
|
||||||
let elements: Vec<Felt> = before_pos
|
let elements: Vec<Felt> = before_pos
|
||||||
.iter()
|
.iter()
|
||||||
.copied()
|
.copied()
|
||||||
|
|
|
@ -287,6 +287,7 @@ fn test_checked_insertion() {
|
||||||
assert_eq!(old_value_1, EMPTY_WORD);
|
assert_eq!(old_value_1, EMPTY_WORD);
|
||||||
|
|
||||||
assert_eq!(prospective, smt.get_leaf(&key_1).hash());
|
assert_eq!(prospective, smt.get_leaf(&key_1).hash());
|
||||||
|
|
||||||
assert_eq!(smt.get_leaf(&key_1), SmtLeaf::Single((key_1, value_1)));
|
assert_eq!(smt.get_leaf(&key_1), SmtLeaf::Single((key_1, value_1)));
|
||||||
|
|
||||||
smt.root()
|
smt.root()
|
||||||
|
|
|
@ -259,6 +259,8 @@ pub(crate) trait SparseMerkleTree<const DEPTH: u8> {
|
||||||
/// Inserts a leaf node, and returns the value at the key if already exists
|
/// Inserts a leaf node, and returns the value at the key if already exists
|
||||||
fn insert_value(&mut self, key: Self::Key, value: Self::Value) -> Option<Self::Value>;
|
fn insert_value(&mut self, key: Self::Key, value: Self::Value) -> Option<Self::Value>;
|
||||||
|
|
||||||
|
/// Returns the value at the specified key. Recall that by definition, any key that hasn't been
|
||||||
|
/// updated is associated with [`Self::EMPTY_VALUE`].
|
||||||
fn get_value(&self, key: &Self::Key) -> Self::Value;
|
fn get_value(&self, key: &Self::Key) -> Self::Value;
|
||||||
|
|
||||||
/// Returns the leaf at the specified index.
|
/// Returns the leaf at the specified index.
|
||||||
|
|
Loading…
Add table
Reference in a new issue