Struct diem_types::proof::accumulator::mock::MockTransactionAccumulator
source · pub struct MockTransactionAccumulator { /* private fields */ }
Expand description
An immutable transaction accumulator (not a summary, since it stores all leaf
nodes and caches internal nodes) that allows for easily computing root hashes,
consistency proofs, etc… at any versions in the range 0..=self.version()
.
This implementation intentionally eschews the existing storage implementation
and Position
APIs to be as different as possible so we can better guarantee
correctness across implementations. Here, we mostly use “naive” recursive
algorithms (with internal caches).
Note: intended for test-only code; panics whenever something goes wrong.
Implementations§
source§impl MockTransactionAccumulator
impl MockTransactionAccumulator
sourcepub fn from_leaves(leaves: Vec<HashValue>) -> Self
pub fn from_leaves(leaves: Vec<HashValue>) -> Self
Create a full transaction accumulator from a list of leaf node hashes.
sourcepub fn with_version(version: Version) -> Self
pub fn with_version(version: Version) -> Self
Create an accumulator with some mock leaf hash values at the given version.
pub fn version(&self) -> Version
sourcepub fn get_root_hash(&self, version: Version) -> HashValue
pub fn get_root_hash(&self, version: Version) -> HashValue
Get the accumulator root hash at a specific version. Note that this method has the side effect of seeding the parent<->child caches.
pub fn get_accumulator_summary( &self, version: Version ) -> TransactionAccumulatorSummary
pub fn get_consistency_proof( &self, start_version: Option<Version>, end_version: Version ) -> AccumulatorConsistencyProof
Trait Implementations§
source§impl Clone for MockTransactionAccumulator
impl Clone for MockTransactionAccumulator
source§fn clone(&self) -> MockTransactionAccumulator
fn clone(&self) -> MockTransactionAccumulator
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more