diff options
Diffstat (limited to 'src/guts.rs')
| -rw-r--r-- | src/guts.rs | 47 |
1 files changed, 3 insertions, 44 deletions
diff --git a/src/guts.rs b/src/guts.rs index ecde326..6bbf5a5 100644 --- a/src/guts.rs +++ b/src/guts.rs @@ -1,13 +1,6 @@ -//! This undocumented and unstable module is for use cases like the `bao` crate, -//! which need to traverse the BLAKE3 Merkle tree and work with chunk and parent -//! chaining values directly. There might be breaking changes to this module -//! between patch versions. -//! -//! We could stabilize something like this module in the future. If you have a -//! use case for it, please let us know by filing a GitHub issue. +//! Deprecated in favor of [`hazmat`](crate::hazmat) -pub const BLOCK_LEN: usize = 64; -pub const CHUNK_LEN: usize = 1024; +pub use crate::{BLOCK_LEN, CHUNK_LEN}; #[derive(Clone, Debug)] pub struct ChunkState(crate::ChunkState); @@ -26,7 +19,7 @@ impl ChunkState { #[inline] pub fn len(&self) -> usize { - self.0.len() + self.0.count() } #[inline] @@ -65,37 +58,3 @@ pub fn parent_cv( output.chaining_value().into() } } - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_chunk() { - assert_eq!( - crate::hash(b"foo"), - ChunkState::new(0).update(b"foo").finalize(true) - ); - } - - #[test] - fn test_parents() { - let mut hasher = crate::Hasher::new(); - let mut buf = [0; crate::CHUNK_LEN]; - - buf[0] = 'a' as u8; - hasher.update(&buf); - let chunk0_cv = ChunkState::new(0).update(&buf).finalize(false); - - buf[0] = 'b' as u8; - hasher.update(&buf); - let chunk1_cv = ChunkState::new(1).update(&buf).finalize(false); - - hasher.update(b"c"); - let chunk2_cv = ChunkState::new(2).update(b"c").finalize(false); - - let parent = parent_cv(&chunk0_cv, &chunk1_cv, false); - let root = parent_cv(&parent, &chunk2_cv, true); - assert_eq!(hasher.finalize(), root); - } -} |
