-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: split SkeletonNode into CurrentSkeletonNode and UpdatedSkeletonNode
- Loading branch information
1 parent
df0c31f
commit 272a0af
Showing
9 changed files
with
71 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
pub mod current_skeleton_node; | ||
pub mod current_skeleton_tree; | ||
pub mod errors; | ||
pub mod filled_node; | ||
pub mod filled_tree; | ||
pub mod skeleton_node; | ||
pub mod skeleton_tree; | ||
pub mod types; | ||
pub mod updated_skeleton_node; | ||
pub mod updated_skeleton_tree; |
15 changes: 15 additions & 0 deletions
15
crates/committer/src/patricia_merkle_tree/current_skeleton_node.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use crate::hash::types::HashOutput; | ||
use crate::patricia_merkle_tree::types::{EdgeData, LeafDataTrait, PathToBottom}; | ||
|
||
#[allow(dead_code)] | ||
/// A node in the structure of a Patricia-Merkle tree, before the update. | ||
pub(crate) enum CurrentSkeletonNode<L: LeafDataTrait> { | ||
Binary, | ||
Edge { path_to_bottom: PathToBottom }, | ||
// Unmodified leaf / binary nodes on the merkle paths of modified leaves. | ||
LeafOrBinarySibling(HashOutput), | ||
// Unmodified edge nodes on the merkle paths of modified leaves. | ||
EdgeSibling(EdgeData), | ||
Leaf(L), | ||
Empty, | ||
} |
19 changes: 19 additions & 0 deletions
19
crates/committer/src/patricia_merkle_tree/current_skeleton_tree.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::collections::HashMap; | ||
|
||
use crate::hash::types::HashFunction; | ||
use crate::patricia_merkle_tree::errors::SkeletonTreeError; | ||
use crate::patricia_merkle_tree::types::{LeafDataTrait, NodeIndex, TreeHashFunction}; | ||
use crate::patricia_merkle_tree::updated_skeleton_tree::UpdatedSkeletonTree; | ||
|
||
/// Consider a Patricia-Merkle Tree which should be updated with new leaves. | ||
/// This trait represents the structure of the subtree which will be modified in the | ||
/// update. It also contains the hashes (for edge siblings - also the edge data) of the Sibling | ||
/// nodes on the Merkle paths from the updated leaves to the root. | ||
pub(crate) trait CurrentSkeletonTree<L: LeafDataTrait, H: HashFunction, TH: TreeHashFunction<L, H>> | ||
{ | ||
/// Computes and returns updated skeleton tree. | ||
fn compute_updated_skeleton_tree( | ||
&self, | ||
index_to_updated_leaf: HashMap<NodeIndex, L>, | ||
) -> Result<impl UpdatedSkeletonTree<L, H, TH>, SkeletonTreeError>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
crates/committer/src/patricia_merkle_tree/skeleton_node.rs
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
crates/committer/src/patricia_merkle_tree/skeleton_tree.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
crates/committer/src/patricia_merkle_tree/updated_skeleton_node.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use crate::hash::types::HashOutput; | ||
use crate::patricia_merkle_tree::types::{LeafDataTrait, PathToBottom}; | ||
|
||
#[allow(dead_code)] | ||
/// A node in the structure of a Patricia-Merkle tree, after the update. | ||
pub(crate) enum UpdatedSkeletonNode<L: LeafDataTrait> { | ||
Binary, | ||
Edge { path_to_bottom: PathToBottom }, | ||
// All unmodified nodes on the merkle paths of modified leaves. | ||
Sibling(HashOutput), | ||
Leaf(L), | ||
} |
14 changes: 14 additions & 0 deletions
14
crates/committer/src/patricia_merkle_tree/updated_skeleton_tree.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use crate::hash::types::HashFunction; | ||
use crate::patricia_merkle_tree::errors::SkeletonTreeError; | ||
use crate::patricia_merkle_tree::filled_tree::FilledTree; | ||
use crate::patricia_merkle_tree::types::{LeafDataTrait, TreeHashFunction}; | ||
|
||
/// Consider a Patricia-Merkle Tree which has been updated with new leaves. | ||
/// This trait represents the structure of the subtree which was modified in the update. | ||
/// It also contains the hashes of the Sibling nodes on the Merkle paths from the updated leaves | ||
/// to the root. | ||
pub(crate) trait UpdatedSkeletonTree<L: LeafDataTrait, H: HashFunction, TH: TreeHashFunction<L, H>> | ||
{ | ||
/// Computes and returns the filled tree. | ||
fn compute_filled_tree(&self) -> Result<impl FilledTree<L>, SkeletonTreeError>; | ||
} |