Restructure cached tree hash files, breaks tests

This commit is contained in:
Paul Hauner
2019-03-28 11:11:20 +11:00
parent 3c7e18bdf3
commit 1285f1e9f8
3 changed files with 299 additions and 293 deletions

View File

@@ -0,0 +1,30 @@
use super::*;
use crate::ssz_encode;
impl CachedTreeHash for u64 {
fn build_cache_bytes(&self) -> Vec<u8> {
merkleize(ssz_encode(self))
}
fn num_bytes(&self) -> usize {
8
}
fn max_num_leaves(&self) -> usize {
1
}
fn cached_hash_tree_root(
&self,
other: &Self,
cache: &mut TreeHashCache,
chunk: usize,
) -> Option<usize> {
if self != other {
let leaf = merkleize(ssz_encode(self));
cache.modify_chunk(chunk, &leaf)?;
}
Some(chunk + 1)
}
}