Skip to content

Commit

Permalink
chore: remove hash generic args from the different tree traits
Browse files Browse the repository at this point in the history
  • Loading branch information
TzahiTaub committed Apr 11, 2024
1 parent a5db564 commit d8a4f44
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::HashMap;

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

Expand All @@ -13,8 +13,7 @@ pub(crate) type OriginalSkeletonTreeResult<T> = Result<T, OriginalSkeletonTreeEr
/// 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 OriginalSkeletonTree<L: LeafDataTrait, H: HashFunction, TH: TreeHashFunction<L, H>>
{
pub(crate) trait OriginalSkeletonTree<L: LeafDataTrait> {
fn compute_original_skeleton_tree(
storage: impl Storage,
leaf_indices: &[NodeIndex],
Expand All @@ -26,5 +25,5 @@ pub(crate) trait OriginalSkeletonTree<L: LeafDataTrait, H: HashFunction, TH: Tre
fn compute_updated_skeleton_tree(
&self,
index_to_updated_leaf: HashMap<NodeIndex, L>,
) -> OriginalSkeletonTreeResult<impl UpdatedSkeletonTree<L, H, TH>>;
) -> OriginalSkeletonTreeResult<impl UpdatedSkeletonTree<L>>;
}
19 changes: 8 additions & 11 deletions crates/committer/src/patricia_merkle_tree/updated_skeleton_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,22 @@ use crate::patricia_merkle_tree::updated_skeleton_node::UpdatedSkeletonNode;
/// 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>>
{
pub(crate) trait UpdatedSkeletonTree<L: LeafDataTrait> {
/// Computes and returns the filled tree.
fn compute_filled_tree(&self) -> Result<impl FilledTree<L>, UpdatedSkeletonTreeError>;
fn compute_filled_tree<H: HashFunction>(
&self,
tree_hash_func: &impl TreeHashFunction<L, H>,
) -> Result<impl FilledTree<L>, UpdatedSkeletonTreeError>;
}

#[allow(dead_code)]
struct UpdatedSkeletonTreeImpl<L: LeafDataTrait, H: HashFunction, TH: TreeHashFunction<L, H>> {
struct UpdatedSkeletonTreeImpl<L: LeafDataTrait> {
skeleton_tree: HashMap<NodeIndex, UpdatedSkeletonNode<L>>,
hash_function: H,
tree_hash_function: TH,
}

#[allow(dead_code)]
impl<
L: LeafDataTrait + std::clone::Clone + std::marker::Sync + std::marker::Send,
H: HashFunction + std::marker::Sync,
TH: TreeHashFunction<L, H> + std::marker::Sync,
> UpdatedSkeletonTreeImpl<L, H, TH>
impl<L: LeafDataTrait + std::clone::Clone + std::marker::Sync + std::marker::Send>
UpdatedSkeletonTreeImpl<L>
{
fn get_sk_tree(&self) -> &HashMap<NodeIndex, UpdatedSkeletonNode<L>> {
&self.skeleton_tree
Expand Down

0 comments on commit d8a4f44

Please sign in to comment.