From 0420607ff130fc8f4b61458267479fb6ad16980b Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sat, 13 Apr 2019 13:02:41 +1000 Subject: [PATCH] Tidy, remove debug prints --- eth2/utils/ssz/src/cached_tree_hash/resize.rs | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/eth2/utils/ssz/src/cached_tree_hash/resize.rs b/eth2/utils/ssz/src/cached_tree_hash/resize.rs index a7bad0b04..21b729c9e 100644 --- a/eth2/utils/ssz/src/cached_tree_hash/resize.rs +++ b/eth2/utils/ssz/src/cached_tree_hash/resize.rs @@ -24,8 +24,6 @@ fn grow_merkle_cache( // Loop through all internal levels of the tree (skipping the final, leaves level). for i in 0..from_height - 1 as usize { - dbg!(i); - dbg!(bytes.len()); // If we're on the leaf slice, grab the first byte and all the of the bytes after that. // This is required because we can have an arbitrary number of bytes at the leaf level // (e.g., the case where there are subtrees as leaves). @@ -37,8 +35,6 @@ fn grow_merkle_cache( old_bytes.get(byte_range_at_height(i)) }?; - dbg!(byte_range_at_height(i + to_height - from_height)); - let new_slice = bytes .get_mut(byte_range_at_height(i + to_height - from_height))? .get_mut(0..old_slice.len())?; @@ -49,6 +45,27 @@ fn grow_merkle_cache( Some(bytes) } +/* +fn copy_bytes( + from_range: Range, + to_range: Range, + from: &[u8], + to: &mut Vec, +) -> Option<()> { + let from_slice = from.get(node_range_to_byte_range(from_range)); + + let to_slice = to + .get_mut(byte_range_at_height(i + to_height - from_height))? + .get_mut(0..old_slice.len())?; + + Ok(()) +} +*/ + +fn node_range_to_byte_range(node_range: Range) -> Range { + node_range.start * HASHSIZE..node_range.end * HASHSIZE +} + fn byte_range_at_height(h: usize) -> Range { first_byte_at_height(h)..last_node_at_height(h) * HASHSIZE }