feat(hashing): fill o with 0s placeholders #146
Signed-off-by: Johns Beharry <johns@peakshift.com>
This commit is contained in:
parent
3411f54c2e
commit
998e2ed7eb
@ -1,8 +1,9 @@
|
||||
use types::{Hash256}
|
||||
use hashing::canonical_hash;
|
||||
|
||||
fn merkle_root(values: Vec<>) -> Hash256 {
|
||||
let o = values.len();
|
||||
fn merkle_root(values: Vec<T>) -> Hash256 {
|
||||
let mut o = vec![0; values.len()];
|
||||
o.append(values);
|
||||
|
||||
for v in &values {
|
||||
canonical_hash(v.as_bytes());
|
||||
@ -19,8 +20,8 @@ mod tests {
|
||||
let test_leaf_2 = canonical_hash(values[1]);
|
||||
let test_leaf_3 = canonical_hash(values[2]);
|
||||
let test_leaf_4 = canonical_hash(values[3]);
|
||||
let test_node_1 = canonical_hash(vec![test_leaf_1, test_leaf_2]);
|
||||
let test_node_2 = canonical_hash(vec![test_leaf_3, test_leaf_4]);
|
||||
let test_node_1 = canonical_hash(vec![test_leaf_4, test_leaf_3]);
|
||||
let test_node_2 = canonical_hash(vec![test_leaf_2, test_leaf_1]);
|
||||
let test_root = canonical_hash(vec![test_node_1, test_node_2]);
|
||||
|
||||
let result = merkle_root(values);
|
||||
|
Loading…
Reference in New Issue
Block a user