Skip to content

Commit

Permalink
loosen bounds on merkle hash arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
preston-evans98 committed May 1, 2023
1 parent 2238d4b commit 60574e0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tendermint/src/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub type Hash = [u8; HASH_SIZE];
/// 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<H>(byte_vecs: &[Vec<u8>]) -> Hash
pub fn simple_hash_from_byte_vectors<H>(byte_vecs: &[impl AsRef<[u8]>]) -> Hash
where
H: MerkleHash + Default,
{
Expand Down Expand Up @@ -48,11 +48,11 @@ pub trait MerkleHash {
// Implements recursion into subtrees.
// Pre and post-conditions: the hasher is in the reset state
// before and after calling this function.
fn hash_byte_vectors(&mut self, byte_vecs: &[Vec<u8>]) -> Hash {
fn hash_byte_vectors(&mut self, byte_vecs: &[impl AsRef<[u8]>]) -> Hash {
let length = byte_vecs.len();
match length {
0 => self.empty_hash(),
1 => self.leaf_hash(&byte_vecs[0]),
1 => self.leaf_hash(byte_vecs[0].as_ref()),
_ => {
let split = length.next_power_of_two() / 2;
let left = self.hash_byte_vectors(&byte_vecs[..split]);
Expand Down

0 comments on commit 60574e0

Please sign in to comment.