pub fn from_tree_slice_with_config(
        data: &[u8],
        leafs: usize,
        config: StoreConfig,
    ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>> {
        ensure!(
            SubTreeArity::to_usize() == 0,
            "Data slice must not have sub-tree layers"
        );
        ensure!(
            TopTreeArity::to_usize() == 0,
            "Data slice must not have a top layer"
        );

        let branches = BaseTreeArity::to_usize();
        let row_count = get_merkle_tree_row_count(leafs, branches);
        let tree_len = get_merkle_tree_len(leafs, branches)?;
        ensure!(
            tree_len == data.len() / E::byte_len(),
            "Inconsistent tree data"
        );

        ensure!(
            is_merkle_tree_size_valid(leafs, branches),
            "MerkleTree size is invalid given the arity"
        );

        let store = S::new_from_slice_with_config(tree_len, branches, &data, config)
            .context("failed to create data store")?;
        let root = store.read_at(store.len() - 1)?;

        Ok(MerkleTree {
            data: Data::BaseTree(store),
            leafs,
            len: tree_len,
            row_count,
            root,
            _a: PhantomData,
            _e: PhantomData,
            _bta: PhantomData,
            _sta: PhantomData,
            _tta: PhantomData,
        })
    }
/// Represent a fully constructed merkle tree from a provided slice.
Represent a fully constructed merkle tree from a provided slice.
Represent a fully constructed merkle tree from a provided slice .
pub fn from_tree_slice_with_config(
        data: &[u8],
        leafs: usize,
        config: StoreConfig,
    ) -> Result<MerkleTree<E, A, S, BaseTreeArity, SubTreeArity, TopTreeArity>> {
        ensure!(
            SubTreeArity::to_usize() == 0,
            "Data slice must not have sub-tree layers"
        );
        ensure!(
            TopTreeArity::to_usize() == 0,
            "Data slice must not have a top layer"
        );
        let branches = BaseTreeArity::to_usize();
        let row_count = get_merkle_tree_row_count(leafs, branches);
        let tree_len = get_merkle_tree_len(leafs, branches)?;
        ensure!(
            tree_len == data.len() / E::byte_len(),
            "Inconsistent tree data"
        );
        ensure!(
            is_merkle_tree_size_valid(leafs, branches),
            "MerkleTree size is invalid given the arity"
        );
        let store = S::new_from_slice_with_config(tree_len, branches, &data, config)
            .context("failed to create data store")?;
        let root = store.read_at(store.len() - 1)?;
        Ok(MerkleTree {
            data: Data::BaseTree(store),
            leafs,
            len: tree_len,
            row_count,
            root,
            _a: PhantomData,
            _e: PhantomData,
            _bta: PhantomData,
            _sta: PhantomData,
            _tta: PhantomData,
        })
    }
pub fn from_tree_slice_with_config ( data : & [ u8 ] , leafs : usize , config : StoreConfig , ) -> Result < MerkleTree < E , A , S , BaseTreeArity , SubTreeArity , TopTreeArity > > { ensure ! ( SubTreeArity to_usize ( ) 0 " " ) ; ensure ! ( TopTreeArity to_usize ( ) 0 " " ) ; let branches = BaseTreeArity :: to_usize ( ) ; let row_count = get_merkle_tree_row_count ( leafs , branches ) ; let tree_len = get_merkle_tree_len ( leafs , branches ) ? ; ensure ! ( tree_len data len ( ) E byte_len ( ) " " ) ; ensure ! ( is_merkle_tree_size_valid ( leafs branches ) " " ) ; let store = S :: new_from_slice_with_config ( tree_len , branches , & data , config ) . context ( " " ) ? ; let root = store . read_at ( store . len ( ) - 1 ) ? ; Ok ( MerkleTree { data : Data :: BaseTree ( store ) , leafs , len : tree_len , row_count , root , _a : PhantomData , _e : PhantomData , _bta : PhantomData , _sta : PhantomData , _tta : PhantomData , } ) }
Represent a fully constructed merkle tree from a provided slice.
Represent a fully constructed merkle tree from a provided slice .
data
&[u8]
leafs
usize
config
StoreConfig