Skip to content

Commit

Permalink
build: add tentative tree API
Browse files Browse the repository at this point in the history
  • Loading branch information
amosStarkware committed Mar 24, 2024
1 parent 40cd251 commit 2176424
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/committer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub mod patricia_merkle_tree;

// TODO(Dori, 3/3/2024): Delete this dummy code.
pub fn dummy() -> u8 {
7
Expand Down
2 changes: 2 additions & 0 deletions crates/committer/src/patricia_merkle_tree.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod node;
pub mod tree;
1 change: 1 addition & 0 deletions crates/committer/src/patricia_merkle_tree/node.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub struct Node {}
12 changes: 12 additions & 0 deletions crates/committer/src/patricia_merkle_tree/tree.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use crate::patricia_merkle_tree::node::Node;

trait Tree {
/// Returns the node with given full (Merkle) index, if it exists.
fn get_node(full_index: u128) -> Option<Node>;

/// Returns the root if the tree is not empty.
fn get_root() -> Option<Node>;

/// Computes the hash of the given node.
fn compute_hash(node: Node) -> [u8; 32];
}

0 comments on commit 2176424

Please sign in to comment.