From 1c161e751f09af5b68b5511ce640b69b12b0f2e3 Mon Sep 17 00:00:00 2001 From: Johns Beharry Date: Wed, 27 Feb 2019 13:47:27 +0100 Subject: [PATCH] chore(*): remove previously cached file from restructure Signed-off-by: Johns Beharry --- beacon_chain/utils/hashing/src/merkle_root.rs | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 beacon_chain/utils/hashing/src/merkle_root.rs diff --git a/beacon_chain/utils/hashing/src/merkle_root.rs b/beacon_chain/utils/hashing/src/merkle_root.rs deleted file mode 100644 index 11307a880..000000000 --- a/beacon_chain/utils/hashing/src/merkle_root.rs +++ /dev/null @@ -1,37 +0,0 @@ -use types::{Hash256} -use hashing::canonical_hash; - -pub fn merkle_root(values: Vec) -> Hash256 { - let mut o: Vec<&[u8]> = vec![0; values.len()]; - let mut value_hashes = vec![]; - for v in values { - value_hashes.push(canonical_hash(v); - } - - o.append(values); - - for i in (0..values.len() - 1).rev() { - canonical_hash(o[i * 2] + o[i * 2 + 1]); - } - - o[1]; -} - -#[cfg(test)] -mod tests { - #[test] - fn calculate_merkle_root() { - let values = vec!["abc", "lmn", "xyz", "o0o"]; - - let test_leaf_0 = canonical_hash(values[0]); - let test_leaf_1 = canonical_hash(values[1]); - let test_leaf_2 = canonical_hash(values[2]); - let test_leaf_3 = canonical_hash(values[3]); - let test_node_0 = canonical_hash(test_leaf_3 + test_leaf_2); - let test_node_1 = canonical_hash(test_leaf_1 + test_leaf_0); - let test_root = canonical_hash(test_node_0 + test_node_0); - - let result = merkle_root(values); - assert_eq!(result, test_root); - } -}