diff --git a/eth2/utils/ssz/src/cached_tree_hash.rs b/eth2/utils/ssz/src/cached_tree_hash.rs index 8a7b07f50..f7d18c57c 100644 --- a/eth2/utils/ssz/src/cached_tree_hash.rs +++ b/eth2/utils/ssz/src/cached_tree_hash.rs @@ -14,7 +14,7 @@ const MERKLE_HASH_CHUNCK: usize = 2 * BYTES_PER_CHUNK; #[derive(Debug, PartialEq, Clone)] pub enum Error { - ShouldNotProduceOffsetHandler, + ShouldNotProduceBTreeOverlay, NoFirstNode, NoBytesForRoot, UnableToObtainSlices, @@ -92,7 +92,7 @@ impl TreeHashCache { where T: CachedTreeHash, { - let offset_handler = OffsetHandler::new(item, 0)?; + let offset_handler = BTreeOverlay::new(item, 0)?; // Note how many leaves were provided. If is not a power-of-two, we'll need to pad it out // later. @@ -263,7 +263,7 @@ fn node_range_to_byte_range(node_range: &Range) -> Range { } #[derive(Debug)] -pub struct OffsetHandler { +pub struct BTreeOverlay { num_internal_nodes: usize, pub num_leaf_nodes: usize, first_node: usize, @@ -271,7 +271,7 @@ pub struct OffsetHandler { offsets: Vec, } -impl OffsetHandler { +impl BTreeOverlay { pub fn new(item: &T, initial_offset: usize) -> Result where T: CachedTreeHash, diff --git a/eth2/utils/ssz/src/cached_tree_hash/impls.rs b/eth2/utils/ssz/src/cached_tree_hash/impls.rs index 558b4dde5..26905c667 100644 --- a/eth2/utils/ssz/src/cached_tree_hash/impls.rs +++ b/eth2/utils/ssz/src/cached_tree_hash/impls.rs @@ -19,7 +19,7 @@ impl CachedTreeHash for u64 { } fn offsets(&self) -> Result, Error> { - Err(Error::ShouldNotProduceOffsetHandler) + Err(Error::ShouldNotProduceBTreeOverlay) } fn num_child_nodes(&self) -> usize { @@ -78,7 +78,7 @@ where let mut offsets = vec![]; for item in self { - offsets.push(OffsetHandler::new(item, 0)?.total_nodes()) + offsets.push(BTreeOverlay::new(item, 0)?.total_nodes()) } offsets @@ -111,11 +111,11 @@ where cache: &mut TreeHashCache, chunk: usize, ) -> Result { - let offset_handler = OffsetHandler::new(self, chunk)?; - let old_offset_handler = OffsetHandler::new(other, chunk)?; + let offset_handler = BTreeOverlay::new(self, chunk)?; + let old_offset_handler = BTreeOverlay::new(other, chunk)?; if offset_handler.num_leaf_nodes != old_offset_handler.num_leaf_nodes { - let old_offset_handler = OffsetHandler::new(other, chunk)?; + let old_offset_handler = BTreeOverlay::new(other, chunk)?; // Get slices of the exsiting tree from the cache. let (old_bytes, old_flags) = cache @@ -180,7 +180,7 @@ where (Some(old), None) => { // Splice out the entire tree of the removed node, replacing it with a // single padding node. - let end_chunk = OffsetHandler::new(old, start_chunk)?.next_node(); + let end_chunk = BTreeOverlay::new(old, start_chunk)?.next_node(); cache.splice( start_chunk..end_chunk, diff --git a/eth2/utils/ssz/src/cached_tree_hash/tests.rs b/eth2/utils/ssz/src/cached_tree_hash/tests.rs index b85c16587..e6e2b1754 100644 --- a/eth2/utils/ssz/src/cached_tree_hash/tests.rs +++ b/eth2/utils/ssz/src/cached_tree_hash/tests.rs @@ -77,7 +77,7 @@ impl CachedTreeHash for Inner { cache: &mut TreeHashCache, chunk: usize, ) -> Result { - let offset_handler = OffsetHandler::new(self, chunk)?; + let offset_handler = BTreeOverlay::new(self, chunk)?; // Skip past the internal nodes and update any changed leaf nodes. { @@ -166,7 +166,7 @@ impl CachedTreeHash for Outer { cache: &mut TreeHashCache, chunk: usize, ) -> Result { - let offset_handler = OffsetHandler::new(self, chunk)?; + let offset_handler = BTreeOverlay::new(self, chunk)?; // Skip past the internal nodes and update any changed leaf nodes. {