Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove hash generic args from the different tree traits #36

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>>;
}
18 changes: 7 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,21 @@ 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, TH: TreeHashFunction<L, H>>(
&self,
) -> 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
Loading