diff --git a/tendermint/src/merkle.rs b/tendermint/src/merkle.rs index e289d73a8..f34f0cc5f 100644 --- a/tendermint/src/merkle.rs +++ b/tendermint/src/merkle.rs @@ -8,9 +8,11 @@ pub const HASH_SIZE: usize = 32; /// Hash is the output of the cryptographic digest function pub type Hash = [u8; HASH_SIZE]; -/// Compute a simple Merkle root from the arbitrary byte arrays -pub fn simple_hash_from_byte_slices(byte_slices: Vec>) -> Hash { - simple_hash_from_byte_slices_inner(byte_slices.as_slice()) +/// Compute a simple Merkle root from vectors of arbitrary byte vectors. +/// The leaves of the tree are the bytes of the given byte vectors in +/// the given order. +pub fn simple_hash_from_byte_vectors(byte_vecs: Vec>) -> Hash { + simple_hash_from_byte_slices_inner(byte_vecs.as_slice()) } // recurse into subtrees @@ -97,7 +99,7 @@ mod tests { let empty_leaf_root = &hex::decode(empty_leaf_root_hex).unwrap(); let empty_tree: Vec> = vec![vec![]; 1]; - let root = simple_hash_from_byte_slices(empty_tree); + let root = simple_hash_from_byte_vectors(empty_tree); assert_eq!(empty_leaf_root, &root); } @@ -109,7 +111,7 @@ mod tests { let leaf_root = &hex::decode(leaf_root_hex).unwrap(); let leaf_tree: Vec> = vec![leaf_string.as_bytes().to_vec(); 1]; - let root = simple_hash_from_byte_slices(leaf_tree); + let root = simple_hash_from_byte_vectors(leaf_tree); assert_eq!(leaf_root, &root); } diff --git a/tendermint/src/validator.rs b/tendermint/src/validator.rs index 8cafe386e..f936de8a9 100644 --- a/tendermint/src/validator.rs +++ b/tendermint/src/validator.rs @@ -26,7 +26,7 @@ impl Set { .into_iter() .map(|x| x.hash_bytes()) .collect(); - merkle::simple_hash_from_byte_slices(validator_bytes) + merkle::simple_hash_from_byte_vectors(validator_bytes) } }