Trait btlib::crypto::merkle_stream::MerkleTree
source · pub trait MerkleTree: Sectored {
// Required methods
fn assert_root_contains(&mut self, hash_data: Option<&[u8]>) -> Result<()>;
fn write(&mut self, offset: usize, data: &[u8]) -> Result<()>;
fn verify(&self, offset: usize, data: &[u8]) -> Result<()>;
fn root_hash(&self) -> Result<&[u8]>;
}
Required Methods§
sourcefn assert_root_contains(&mut self, hash_data: Option<&[u8]>) -> Result<()>
fn assert_root_contains(&mut self, hash_data: Option<&[u8]>) -> Result<()>
Checks that the root node contains the given hash data. If it does then Ok(())
is
returned. If it doesn’t, then Err(Error::HashCmpFailure)
is returned.
sourcefn write(&mut self, offset: usize, data: &[u8]) -> Result<()>
fn write(&mut self, offset: usize, data: &[u8]) -> Result<()>
Hashes the given data, adds a new node to the tree with its hash and updates the hashes of all parent nodes.