pub fn calc_merkleroot_hash(mut hashs: Vec<U256>) -> U256 {
    assert!(0 < hashs.len());
    let mut buf = [0u8; 64];
    let mut new_hashs = Vec::with_capacity(hashs.len() / 2);
    while 1 < hashs.len() {
        if hashs.len() % 2 == 0 {
            new_hashs.clear();
            for i in 0..(hashs.len() / 2) {
                hashs[i * 2].to_big_endian(&mut buf[0..32]);
                hashs[i * 2 + 1].to_big_endian(&mut buf[32..64]);
                let hash = sha256double(buf.as_ref());
                new_hashs.push(U256::from(hash.as_slice()));
            }
            // swap
            hashs = new_hashs.clone();
        } else {
            let last = hashs.last().unwrap().clone();
            hashs.push(last);
        }
    }
    // check
    hashs.pop().unwrap()
}
/// calculate merkleroot hash
///
/// panic if you input empty hashs
calculate merkleroot hash
panic if you input empty hashs
calculate merkleroot hash panic if you input empty hashs
pub fn calc_merkleroot_hash(mut hashs: Vec<U256>) -> U256 {
    assert!(0 < hashs.len());
    let mut buf = [0u8; 64];
    let mut new_hashs = Vec::with_capacity(hashs.len() / 2);
    while 1 < hashs.len() {
        if hashs.len() % 2 == 0 {
            new_hashs.clear();
            for i in 0..(hashs.len() / 2) {
                hashs[i * 2].to_big_endian(&mut buf[0..32]);
                hashs[i * 2 + 1].to_big_endian(&mut buf[32..64]);
                let hash = sha256double(buf.as_ref());
                new_hashs.push(U256::from(hash.as_slice()));
            }
            // swap
            hashs = new_hashs.clone();
        } else {
            let last = hashs.last().unwrap().clone();
            hashs.push(last);
        }
    }
    // check
    hashs.pop().unwrap()
}
pub fn calc_merkleroot_hash ( mut hashs : Vec < U256 > ) -> U256 { assert ! ( 0 hashs len ( ) ) ; let mut buf = [ 0u8 ; 64 ] ; let mut new_hashs = Vec :: with_capacity ( hashs . len ( ) / 2 ) ; while 1 < hashs . len ( ) { if hashs . len ( ) % 2 == 0 { new_hashs . clear ( ) ; for i in 0 .. ( hashs . len ( ) / 2 ) { hashs [ i * 2 ] . to_big_endian ( & mut buf [ 0 .. 32 ] ) ; hashs [ i * 2 + 1 ] . to_big_endian ( & mut buf [ 32 .. 64 ] ) ; let hash = sha256double ( buf . as_ref ( ) ) ; new_hashs . push ( U256 :: from ( hash . as_slice ( ) ) ) ; } // swap hashs = new_hashs . clone ( ) ; } else { let last = hashs . last ( ) . unwrap ( ) . clone ( ) ; hashs . push ( last ) ; } } // check hashs . pop ( ) . unwrap ( ) }
calculate merkleroot hash
panic if you input empty hashs
calculate merkleroot hash panic if you input empty hashs
hashs
Vec<U256>
hashs
Vec<U256>