Remove num_bytes method
This commit is contained in:
parent
cb9b59b93d
commit
c18cdf2abf
@ -18,16 +18,12 @@ impl CachedTreeHash<u64> for u64 {
|
||||
BTreeOverlay::from_lengths(chunk_offset, vec![1])
|
||||
}
|
||||
|
||||
fn num_bytes(&self) -> usize {
|
||||
8
|
||||
}
|
||||
|
||||
fn packed_encoding(&self) -> Result<Vec<u8>, Error> {
|
||||
Ok(ssz_encode(self))
|
||||
}
|
||||
|
||||
fn packing_factor() -> usize {
|
||||
32 / 8
|
||||
HASHSIZE / 8
|
||||
}
|
||||
|
||||
fn cached_hash_tree_root(
|
||||
@ -86,10 +82,6 @@ where
|
||||
BTreeOverlay::from_lengths(chunk_offset, lengths)
|
||||
}
|
||||
|
||||
fn num_bytes(&self) -> usize {
|
||||
self.iter().fold(0, |acc, item| acc + item.num_bytes())
|
||||
}
|
||||
|
||||
fn packed_encoding(&self) -> Result<Vec<u8>, Error> {
|
||||
Err(Error::ShouldNeverBePacked(Self::item_type()))
|
||||
}
|
||||
@ -219,7 +211,7 @@ fn get_packed_leaves<T>(vec: &Vec<T>) -> Result<Vec<u8>, Error>
|
||||
where
|
||||
T: CachedTreeHash<T>,
|
||||
{
|
||||
let num_packed_bytes = vec.num_bytes();
|
||||
let num_packed_bytes = (BYTES_PER_CHUNK / T::packing_factor()) * vec.len();
|
||||
let num_leaves = num_sanitized_leaves(num_packed_bytes);
|
||||
|
||||
let mut packed = Vec::with_capacity(num_leaves * HASHSIZE);
|
||||
|
@ -42,10 +42,6 @@ pub trait CachedTreeHash<Item>: Debug {
|
||||
|
||||
fn build_tree_hash_cache(&self) -> Result<TreeHashCache, Error>;
|
||||
|
||||
/// Return the number of bytes when this element is encoded as raw SSZ _without_ length
|
||||
/// prefixes.
|
||||
fn num_bytes(&self) -> usize;
|
||||
|
||||
fn btree_overlay(&self, chunk_offset: usize) -> Result<BTreeOverlay, Error>;
|
||||
|
||||
fn packed_encoding(&self) -> Result<Vec<u8>, Error>;
|
||||
|
@ -33,17 +33,6 @@ impl CachedTreeHash<Inner> for Inner {
|
||||
Ok(tree)
|
||||
}
|
||||
|
||||
fn num_bytes(&self) -> usize {
|
||||
let mut bytes = 0;
|
||||
|
||||
bytes += self.a.num_bytes();
|
||||
bytes += self.b.num_bytes();
|
||||
bytes += self.c.num_bytes();
|
||||
bytes += self.d.num_bytes();
|
||||
|
||||
bytes
|
||||
}
|
||||
|
||||
fn btree_overlay(&self, chunk_offset: usize) -> Result<BTreeOverlay, Error> {
|
||||
let mut lengths = vec![];
|
||||
|
||||
@ -115,14 +104,6 @@ impl CachedTreeHash<Outer> for Outer {
|
||||
Ok(tree)
|
||||
}
|
||||
|
||||
fn num_bytes(&self) -> usize {
|
||||
let mut bytes = 0;
|
||||
bytes += self.a.num_bytes();
|
||||
bytes += self.b.num_bytes();
|
||||
bytes += self.c.num_bytes();
|
||||
bytes
|
||||
}
|
||||
|
||||
fn btree_overlay(&self, chunk_offset: usize) -> Result<BTreeOverlay, Error> {
|
||||
let mut lengths = vec![];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user