feat: add merkle store

This commit is contained in:
Augusto F. Hack
2023-03-14 00:10:54 +01:00
parent 2871e4eb27
commit 88a646031f
8 changed files with 675 additions and 9 deletions

View File

@@ -15,7 +15,7 @@ mod tests;
pub struct SimpleSmt {
root: Word,
depth: u8,
store: Store,
pub(crate) store: Store,
}
impl SimpleSmt {
@@ -207,17 +207,17 @@ impl SimpleSmt {
/// respectively. Hashes for blank subtrees at each layer are stored in `empty_hashes`, beginning
/// with the root hash of an empty tree, and ending with the zero value of a leaf node.
#[derive(Debug, Clone, PartialEq, Eq)]
struct Store {
branches: BTreeMap<NodeIndex, BranchNode>,
pub(crate) struct Store {
pub(crate) branches: BTreeMap<NodeIndex, BranchNode>,
leaves: BTreeMap<u64, Word>,
empty_hashes: Vec<RpoDigest>,
pub(crate) empty_hashes: Vec<RpoDigest>,
depth: u8,
}
#[derive(Debug, Default, Clone, PartialEq, Eq)]
struct BranchNode {
left: RpoDigest,
right: RpoDigest,
pub(crate) struct BranchNode {
pub(crate) left: RpoDigest,
pub(crate) right: RpoDigest,
}
impl Store {