pub fn create_lcmerkle_tree<H: Hasher>(
    config: Option<StoreConfig>,
    size: usize,
    data: &[u8],
) -> Result<LCMerkleTree<H::Domain, H::Function>> {
    ensure!(
        data.len() == (NODE_SIZE * size) as usize,
        Error::InvalidMerkleTreeArgs(data.len(), NODE_SIZE, size)
    );
    trace!("create_lcmerkle_tree called with size {}", size);

    let f = |i| {
        // TODO Replace `expect()` with `context()` (problem is the parallel iterator)
        let d = data_at_node(&data, i).expect("data_at_node math failed");
        // TODO/FIXME: This can panic. FOR NOW, let's leave this since we're experimenting with
        // optimization paths. However, we need to ensure that bad input will not lead to a panic
        // that isn't caught by the FPS API.
        // Unfortunately, it's not clear how to perform this error-handling in the parallel
        // iterator case.
        H::Domain::try_from_bytes(d).expect("failed to convert node data to domain element")
    };

    match config {
        Some(x) => LCMerkleTree::from_par_iter_with_config((0..size).into_par_iter().map(f), x),
        None => LCMerkleTree::from_par_iter((0..size).into_par_iter().map(f)),
    }
}
/// Construct a new level cache merkle tree.
Construct a new level cache merkle tree.
Construct a new level cache merkle tree .
pub fn create_lcmerkle_tree<H: Hasher>(
    config: Option<StoreConfig>,
    size: usize,
    data: &[u8],
) -> Result<LCMerkleTree<H::Domain, H::Function>> {
    ensure!(
        data.len() == (NODE_SIZE * size) as usize,
        Error::InvalidMerkleTreeArgs(data.len(), NODE_SIZE, size)
    );
    trace!("create_lcmerkle_tree called with size {}", size);
    let f = |i| {
        // TODO Replace `expect()` with `context()` (problem is the parallel iterator)
        let d = data_at_node(&data, i).expect("data_at_node math failed");
        // TODO/FIXME: This can panic. FOR NOW, let's leave this since we're experimenting with
        // optimization paths. However, we need to ensure that bad input will not lead to a panic
        // that isn't caught by the FPS API.
        // Unfortunately, it's not clear how to perform this error-handling in the parallel
        // iterator case.
        H::Domain::try_from_bytes(d).expect("failed to convert node data to domain element")
    };
    match config {
        Some(x) => LCMerkleTree::from_par_iter_with_config((0..size).into_par_iter().map(f), x),
        None => LCMerkleTree::from_par_iter((0..size).into_par_iter().map(f)),
    }
}
pub fn create_lcmerkle_tree < H : Hasher > ( config : Option < StoreConfig > , size : usize , data : & [ u8 ] , ) -> Result < LCMerkleTree < H :: Domain , H :: Function > > { ensure ! ( data len ( ) ( NODE_SIZE size ) as usize Error InvalidMerkleTreeArgs ( data len ( ) NODE_SIZE size ) ) ; trace ! ( " " size ) ; let f = | i | { // TODO Replace `expect()` with `context()` (problem is the parallel iterator) let d = data_at_node ( & data , i ) . expect ( " " ) ; // TODO/FIXME: This can panic. FOR NOW, let's leave this since we're experimenting with // optimization paths. However, we need to ensure that bad input will not lead to a panic // that isn't caught by the FPS API. // Unfortunately, it's not clear how to perform this error-handling in the parallel // iterator case. H :: Domain :: try_from_bytes ( d ) . expect ( " " ) } ; match config { Some ( x ) => LCMerkleTree :: from_par_iter_with_config ( ( 0 .. size ) . into_par_iter ( ) . map ( f ) , x ) , None => LCMerkleTree :: from_par_iter ( ( 0 .. size ) . into_par_iter ( ) . map ( f ) ) , } }
Construct a new level cache merkle tree.
Construct a new level cache merkle tree .
config
Option<StoreConfig>
size
usize
data
&[u8]
config
Option<StoreConfig>
size
usize
data
&[u8]