chore(hashing): update comments of fn merkle_root
Signed-off-by: Johns Beharry <johns@peakshift.com>
This commit is contained in:
parent
1c161e751f
commit
8429f3bff1
@ -8,13 +8,11 @@ pub fn hash(input: &[u8]) -> Vec<u8> {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate Merkle Root
|
// Get merkle root of some hashed values - the input leaf nodes is expected to already be hashed
|
||||||
///
|
// Outputs a `Vec<u8>` byte array of the merkle root given a set of leaf node values.
|
||||||
/// Outputs a `Vec<u8>` byte array of the merkle root given a set of leaf node values.
|
|
||||||
/// Expects leaf nodes to already be hashed.
|
|
||||||
pub fn merkle_root(values: &[Vec<u8>]) -> Vec<u8> {
|
pub fn merkle_root(values: &[Vec<u8>]) -> Vec<u8> {
|
||||||
let values_len = values.len();
|
let values_len = values.len();
|
||||||
|
|
||||||
// vector to store hashes
|
// vector to store hashes
|
||||||
// filled with 0 as placeholders
|
// filled with 0 as placeholders
|
||||||
let mut o: Vec<Vec<u8>> = vec![vec![0]; values_len];
|
let mut o: Vec<Vec<u8>> = vec![vec![0]; values_len];
|
||||||
@ -82,6 +80,5 @@ mod tests {
|
|||||||
let expected = hash(&root[..]);
|
let expected = hash(&root[..]);
|
||||||
|
|
||||||
assert_eq!(&expected[..], output.as_slice());
|
assert_eq!(&expected[..], output.as_slice());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user