spec: ensure types up to date with v0.6.1

This commit is contained in:
Michael Sproul
2019-05-15 11:48:09 +10:00
parent 9f6b7eb757
commit 3a0f00215d
22 changed files with 78 additions and 64 deletions

View File

@@ -51,24 +51,31 @@ impl TreeHash for bool {
}
}
impl TreeHash for [u8; 4] {
fn tree_hash_type() -> TreeHashType {
TreeHashType::Vector
}
macro_rules! impl_for_u8_array {
($len: expr) => {
impl TreeHash for [u8; $len] {
fn tree_hash_type() -> TreeHashType {
TreeHashType::Vector
}
fn tree_hash_packed_encoding(&self) -> Vec<u8> {
unreachable!("bytesN should never be packed.")
}
fn tree_hash_packed_encoding(&self) -> Vec<u8> {
unreachable!("bytesN should never be packed.")
}
fn tree_hash_packing_factor() -> usize {
unreachable!("bytesN should never be packed.")
}
fn tree_hash_packing_factor() -> usize {
unreachable!("bytesN should never be packed.")
}
fn tree_hash_root(&self) -> Vec<u8> {
merkle_root(&self[..])
}
fn tree_hash_root(&self) -> Vec<u8> {
merkle_root(&self[..])
}
}
};
}
impl_for_u8_array!(4);
impl_for_u8_array!(32);
impl TreeHash for H256 {
fn tree_hash_type() -> TreeHashType {
TreeHashType::Vector