Skip to content

Commit

Permalink
refactor: rename current skeleton to original (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
TzahiTaub authored Apr 11, 2024
1 parent 50c1d13 commit a5db564
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions crates/committer/src/patricia_merkle_tree.rs
Original file line number Diff line number Diff line change
@@ -1,8 +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 original_skeleton_node;
pub mod original_skeleton_tree;
pub mod types;
pub mod updated_skeleton_node;
pub mod updated_skeleton_tree;
2 changes: 1 addition & 1 deletion crates/committer/src/patricia_merkle_tree/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// TODO(Amos, 01/04/2024): Add error types.
#[derive(Debug)]
pub(crate) enum CurrentSkeletonTreeError {}
pub(crate) enum OriginalSkeletonTreeError {}

#[derive(Debug)]
pub(crate) enum UpdatedSkeletonTreeError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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> {
pub(crate) enum OriginalSkeletonNode<L: LeafDataTrait> {
Binary,
Edge { path_to_bottom: PathToBottom },
// Unmodified leaf / binary nodes on the merkle paths of modified leaves.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
use std::collections::HashMap;

use crate::hash::types::{HashFunction, HashOutput};
use crate::patricia_merkle_tree::errors::CurrentSkeletonTreeError;
use crate::patricia_merkle_tree::errors::OriginalSkeletonTreeError;
use crate::patricia_merkle_tree::types::{LeafDataTrait, NodeIndex, TreeHashFunction, TreeHeight};
use crate::patricia_merkle_tree::updated_skeleton_tree::UpdatedSkeletonTree;
use crate::storage::storage_trait::Storage;

#[allow(dead_code)]
pub(crate) type CurrentSkeletonTreeResult<T> = Result<T, CurrentSkeletonTreeError>;
pub(crate) type OriginalSkeletonTreeResult<T> = Result<T, OriginalSkeletonTreeError>;

/// 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>>
pub(crate) trait OriginalSkeletonTree<L: LeafDataTrait, H: HashFunction, TH: TreeHashFunction<L, H>>
{
fn compute_current_skeleton_tree(
fn compute_original_skeleton_tree(
storage: impl Storage,
leaf_indices: &[NodeIndex],
root_hash: HashOutput,
tree_height: TreeHeight,
) -> CurrentSkeletonTreeResult<Box<Self>>;
) -> OriginalSkeletonTreeResult<Box<Self>>;

/// Computes and returns updated skeleton tree.
fn compute_updated_skeleton_tree(
&self,
index_to_updated_leaf: HashMap<NodeIndex, L>,
) -> CurrentSkeletonTreeResult<impl UpdatedSkeletonTree<L, H, TH>>;
) -> OriginalSkeletonTreeResult<impl UpdatedSkeletonTree<L, H, TH>>;
}

0 comments on commit a5db564

Please sign in to comment.