commit
c1fa20b3e1
@ -2,8 +2,8 @@ use super::*;
|
|||||||
|
|
||||||
/// A schema defining a binary tree over a `TreeHashCache`.
|
/// A schema defining a binary tree over a `TreeHashCache`.
|
||||||
///
|
///
|
||||||
/// This structure is used for succinct storage, run-time functionality is gained by converting the
|
/// This structure is used for succinct storage; run-time functionality is gained by converting a
|
||||||
/// schema into a `BTreeOverlay`.
|
/// `BTreeSchema` into a `BTreeOverlay`.
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub struct BTreeSchema {
|
pub struct BTreeSchema {
|
||||||
/// The depth of a schema defines how far it is nested within other fixed-length items.
|
/// The depth of a schema defines how far it is nested within other fixed-length items.
|
||||||
@ -48,8 +48,8 @@ pub enum LeafNode {
|
|||||||
Padding,
|
Padding,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Instantiated from a `BTreeSchema`, allows for interpreting some chunks of a `TreeHashCache` as
|
/// Instantiated from a `BTreeSchema`, a `BTreeOverlay` allows for interpreting some
|
||||||
/// a perfect binary tree.
|
/// non-consecutive chunks of a `TreeHashCache` as a perfect binary tree.
|
||||||
///
|
///
|
||||||
/// The primary purpose of this struct is to map from binary tree "nodes" to `TreeHashCache`
|
/// The primary purpose of this struct is to map from binary tree "nodes" to `TreeHashCache`
|
||||||
/// "chunks". Each tree has nodes `0..n` where `n` is the number of nodes and `0` is the root node.
|
/// "chunks". Each tree has nodes `0..n` where `n` is the number of nodes and `0` is the root node.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
//! Performs cached merkle-hashing adhering to the Ethereum 2.0 specification defined
|
//! Performs cached merkle-hashing adhering to the Ethereum 2.0 specification defined
|
||||||
//! [here](https://github.com/ethereum/eth2.0-specs/blob/v0.5.1/specs/simple-serialize.md#merkleization).
|
//! [here](https://github.com/ethereum/eth2.0-specs/blob/v0.5.1/specs/simple-serialize.md#merkleization).
|
||||||
//!
|
//!
|
||||||
//! Caching allows for reduced hashing when some object has only been partially modified. This
|
//! Caching allows for reduced hashing when some object has only been partially modified, which
|
||||||
//! allows for significant CPU-time savings (at the cost of additional storage). For example,
|
//! consumes less CPU-time at the cost of additional storage. For example,
|
||||||
//! determining the root of a list of 1024 items with a single modification has been observed to
|
//! determining the root of a list of 1024 items with a single modification has been observed to
|
||||||
//! run in 1/25th of the time of a full merkle hash.
|
//! run in 1/25th of the time of a full merkle hash.
|
||||||
//!
|
//!
|
||||||
@ -61,8 +61,8 @@ pub trait CachedTreeHash: TreeHash {
|
|||||||
fn update_tree_hash_cache(&self, cache: &mut TreeHashCache) -> Result<(), Error>;
|
fn update_tree_hash_cache(&self, cache: &mut TreeHashCache) -> Result<(), Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implements `CachedTreeHash` on `$type` as a fixed-length tree-hash vector of the ssz encoding
|
/// Implements `CachedTreeHash` on `$type`, where `$type` is a fixed-length vector and each item in
|
||||||
/// of `$type`.
|
/// the `$type` is encoded as bytes using `ssz_encode`.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! cached_tree_hash_ssz_encoding_as_vector {
|
macro_rules! cached_tree_hash_ssz_encoding_as_vector {
|
||||||
($type: ident, $num_bytes: expr) => {
|
($type: ident, $num_bytes: expr) => {
|
||||||
@ -95,8 +95,8 @@ macro_rules! cached_tree_hash_ssz_encoding_as_vector {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implements `CachedTreeHash` on `$type` as a variable-length tree-hash list of the result of
|
/// Implements `CachedTreeHash` on `$type`, where `$type` is a variable-length list and each item
|
||||||
/// calling `.as_bytes()` on `$type`.
|
/// in `$type` is encoded as bytes by calling `item.to_bytes()`.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! cached_tree_hash_bytes_as_list {
|
macro_rules! cached_tree_hash_bytes_as_list {
|
||||||
($type: ident) => {
|
($type: ident) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user