fix(hashing): reverse loop #146

Signed-off-by: Johns Beharry <johns@peakshift.com>
This commit is contained in:
Johns Beharry 2019-01-12 10:38:58 -04:00
parent 998e2ed7eb
commit fa2bae4cc1
No known key found for this signature in database
GPG Key ID: EC114974742E2178

View File

@ -1,11 +1,12 @@
use types::{Hash256} use types::{Hash256}
use hashing::canonical_hash; use hashing::canonical_hash;
use std::iter::range_step;
fn merkle_root(values: Vec<T>) -> Hash256 { fn merkle_root(values: Vec<T>) -> Hash256 {
let mut o = vec![0; values.len()]; let mut o = vec![0; values.len()];
o.append(values); o.append(values);
for v in &values { for v in range_step(values - 1, 0, -1) {
canonical_hash(v.as_bytes()); canonical_hash(v.as_bytes());
} }
} }