2019-04-15 23:14:33 +00:00
|
|
|
pub mod cached_tree_hash;
|
|
|
|
pub mod standard_tree_hash;
|
2019-04-15 01:14:30 +00:00
|
|
|
|
|
|
|
pub const BYTES_PER_CHUNK: usize = 32;
|
|
|
|
pub const HASHSIZE: usize = 32;
|
|
|
|
pub const MERKLE_HASH_CHUNCK: usize = 2 * BYTES_PER_CHUNK;
|
|
|
|
|
2019-04-15 23:34:23 +00:00
|
|
|
pub use cached_tree_hash::CachedTreeHashSubTree;
|
|
|
|
pub use standard_tree_hash::TreeHash;
|
|
|
|
|
2019-04-15 01:14:30 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2019-04-15 23:34:23 +00:00
|
|
|
pub enum TreeHashType {
|
2019-04-15 01:14:30 +00:00
|
|
|
Basic,
|
|
|
|
List,
|
|
|
|
Composite,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn num_sanitized_leaves(num_bytes: usize) -> usize {
|
|
|
|
let leaves = (num_bytes + HASHSIZE - 1) / HASHSIZE;
|
|
|
|
leaves.next_power_of_two()
|
|
|
|
}
|
|
|
|
|
2019-04-15 23:14:33 +00:00
|
|
|
fn num_nodes(num_leaves: usize) -> usize {
|
|
|
|
2 * num_leaves - 1
|
2019-04-15 01:14:30 +00:00
|
|
|
}
|