Skip to content

Commit

Permalink
feat(mpt): Trie node insertion
Browse files Browse the repository at this point in the history
Adds a new function to the `TrieNode` struct, `insert`, that allows for
inserting a new leaf at a given path.

add static insertion test
  • Loading branch information
clabby committed Jun 1, 2024
1 parent 044570b commit 94ade37
Show file tree
Hide file tree
Showing 2 changed files with 300 additions and 78 deletions.
4 changes: 3 additions & 1 deletion crates/mpt/src/list_walker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ where
}
Ok(leaf_values)
}
TrieNode::Leaf { key, value } => Ok(vec![(key.clone(), value.clone())].into()),
TrieNode::Leaf { prefix, value } => {
Ok(vec![(prefix.to_vec().into(), value.clone())].into())
}
TrieNode::Extension { node, .. } => {
// If the node is a hash, we need to grab the preimage for it and continue
// recursing. If it is already retrieved, recurse on it.
Expand Down
Loading

0 comments on commit 94ade37

Please sign in to comment.