now using the Hashtree macro for most struct types

This commit is contained in:
mjkeating
2019-02-22 13:07:04 -08:00
parent e9f4cc134e
commit f95a0134e6
26 changed files with 110 additions and 363 deletions

View File

@@ -32,6 +32,12 @@ impl TreeHash for usize {
}
}
impl TreeHash for bool {
fn hash_tree_root_internal(&self) -> Vec<u8> {
ssz_encode(self)
}
}
impl TreeHash for Address {
fn hash_tree_root_internal(&self) -> Vec<u8> {
ssz_encode(self)

View File

@@ -7,9 +7,7 @@ pub trait TreeHash {
fn hash_tree_root_internal(&self) -> Vec<u8>;
fn hash_tree_root(&self) -> Vec<u8> {
let mut result = self.hash_tree_root_internal();
if result.len() < HASHSIZE {
zpad(&mut result, HASHSIZE);
}
zpad(&mut result, HASHSIZE);
result
}
}