pub fn generate_leaves(data: Vec<u8>, crypto: &Provider) -> Result<Vec<Node>, Error> {
    let chunk_size = get_chunk_size(data.len());
    let data_chunks: Vec<&[u8]> = data.chunks(chunk_size).collect();

    let mut leaves = Vec::<Node>::new();
    let mut min_byte_range = 0;
    for chunk in data_chunks.into_iter() {
        let data_hash = crypto.hash_sha256(chunk)?;
        let max_byte_range = min_byte_range + &chunk.len();
        let offset = max_byte_range.to_note_vec();
        let id = crypto.hash_all_sha256(vec![&data_hash, &offset])?;

        leaves.push(Node {
            id,
            data_hash: Some(data_hash),
            min_byte_range,
            max_byte_range,
            left_child: None,
            right_child: None,
        });
        min_byte_range = min_byte_range + &chunk.len();
    }
    Ok(leaves)
}
/// Generates data chunks from which the calculation of root id starts.
Generates data chunks from which the calculation of root id starts.
Generates data chunks from which the calculation of root id starts .
pub fn generate_leaves(data: Vec<u8>, crypto: &Provider) -> Result<Vec<Node>, Error> {
    let chunk_size = get_chunk_size(data.len());
    let data_chunks: Vec<&[u8]> = data.chunks(chunk_size).collect();
    let mut leaves = Vec::<Node>::new();
    let mut min_byte_range = 0;
    for chunk in data_chunks.into_iter() {
        let data_hash = crypto.hash_sha256(chunk)?;
        let max_byte_range = min_byte_range + &chunk.len();
        let offset = max_byte_range.to_note_vec();
        let id = crypto.hash_all_sha256(vec![&data_hash, &offset])?;
        leaves.push(Node {
            id,
            data_hash: Some(data_hash),
            min_byte_range,
            max_byte_range,
            left_child: None,
            right_child: None,
        });
        min_byte_range = min_byte_range + &chunk.len();
    }
    Ok(leaves)
}
pub fn generate_leaves ( data : Vec < u8 > , crypto : & Provider ) -> Result < Vec < Node > , Error > { let chunk_size = get_chunk_size ( data . len ( ) ) ; let data_chunks : Vec < & [ u8 ] > = data . chunks ( chunk_size ) . collect ( ) ; let mut leaves = Vec :: < Node > :: new ( ) ; let mut min_byte_range = 0 ; for chunk in data_chunks . into_iter ( ) { let data_hash = crypto . hash_sha256 ( chunk ) ? ; let max_byte_range = min_byte_range + & chunk . len ( ) ; let offset = max_byte_range . to_note_vec ( ) ; let id = crypto . hash_all_sha256 ( vec ! [ data_hash offset ] ) ? ; leaves . push ( Node { id , data_hash : Some ( data_hash ) , min_byte_range , max_byte_range , left_child : None , right_child : None , } ) ; min_byte_range = min_byte_range + & chunk . len ( ) ; } Ok ( leaves ) }
Generates data chunks from which the calculation of root id starts.
Generates data chunks from which the calculation of root id starts .
data
Vec<u8>
crypto
&Provider
data
Vec<u8>
crypto
&Provider