From fa2bae4cc1fc2dc177358df15bfe68832051a4cf Mon Sep 17 00:00:00 2001 From: Johns Beharry Date: Sat, 12 Jan 2019 10:38:58 -0400 Subject: [PATCH] fix(hashing): reverse loop #146 Signed-off-by: Johns Beharry --- beacon_chain/utils/hashing/src/merkle_root.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beacon_chain/utils/hashing/src/merkle_root.rs b/beacon_chain/utils/hashing/src/merkle_root.rs index 9a05ed450..345c491c5 100644 --- a/beacon_chain/utils/hashing/src/merkle_root.rs +++ b/beacon_chain/utils/hashing/src/merkle_root.rs @@ -1,11 +1,12 @@ use types::{Hash256} use hashing::canonical_hash; +use std::iter::range_step; fn merkle_root(values: Vec) -> Hash256 { let mut o = vec![0; values.len()]; o.append(values); - for v in &values { + for v in range_step(values - 1, 0, -1) { canonical_hash(v.as_bytes()); } }