Struct accumulator::MerkleAccumulator
source · pub struct MerkleAccumulator<R, H> { /* private fields */ }
Expand description
In this live Merkle Accumulator algorithms.
Implementations§
source§impl<R, H> MerkleAccumulator<R, H>where
R: HashReader,
H: CryptoHasher,
impl<R, H> MerkleAccumulator<R, H>where
R: HashReader,
H: CryptoHasher,
sourcepub fn append(
reader: &R,
num_existing_leaves: LeafCount,
new_leaves: &[HashValue]
) -> Result<(HashValue, Vec<(Position, HashValue)>)>
pub fn append( reader: &R, num_existing_leaves: LeafCount, new_leaves: &[HashValue] ) -> Result<(HashValue, Vec<(Position, HashValue)>)>
Given an existing Merkle Accumulator (represented by
num_existing_leaves
and a reader
that is able to fetch all
existing frozen nodes), and a list of leaves to be appended, returns
the result root hash and new nodes to be frozen.
sourcepub fn get_proof(
reader: &R,
num_leaves: LeafCount,
leaf_index: u64
) -> Result<AccumulatorProof<H>>
pub fn get_proof( reader: &R, num_leaves: LeafCount, leaf_index: u64 ) -> Result<AccumulatorProof<H>>
Get proof of inclusion of the leaf at leaf_index
in this Merkle
Accumulator of num_leaves
leaves in total. Siblings are read via
reader
(or generated dynamically if they are non-frozen).
See diem_types::proof::AccumulatorProof
for proof format.
sourcepub fn get_consistency_proof(
reader: &R,
full_acc_leaves: LeafCount,
sub_acc_leaves: LeafCount
) -> Result<AccumulatorConsistencyProof>
pub fn get_consistency_proof( reader: &R, full_acc_leaves: LeafCount, sub_acc_leaves: LeafCount ) -> Result<AccumulatorConsistencyProof>
Gets a proof that shows the full accumulator is consistent with a smaller accumulator.
See diem_types::proof::AccumulatorConsistencyProof
for proof format.
sourcepub fn get_range_proof(
reader: &R,
full_acc_leaves: LeafCount,
first_leaf_index: Option<u64>,
num_leaves: LeafCount
) -> Result<AccumulatorRangeProof<H>>
pub fn get_range_proof( reader: &R, full_acc_leaves: LeafCount, first_leaf_index: Option<u64>, num_leaves: LeafCount ) -> Result<AccumulatorRangeProof<H>>
Gets a proof that shows a range of leaves are part of the accumulator.
See diem_types::proof::AccumulatorRangeProof
for proof format.
sourcepub fn get_range_proof_positions(
reader: &R,
full_acc_leaves: LeafCount,
first_leaf_index: Option<u64>,
num_leaves: LeafCount
) -> Result<(Vec<Position>, Vec<Position>)>
pub fn get_range_proof_positions( reader: &R, full_acc_leaves: LeafCount, first_leaf_index: Option<u64>, num_leaves: LeafCount ) -> Result<(Vec<Position>, Vec<Position>)>
See get_range_proof
. This is the version of it that returns
Position
s only.
sourcepub fn get_frozen_subtree_hashes(
reader: &R,
num_leaves: LeafCount
) -> Result<Vec<HashValue>>
pub fn get_frozen_subtree_hashes( reader: &R, num_leaves: LeafCount ) -> Result<Vec<HashValue>>
From left to right, gets frozen subtree root hashes of the accumulator.
For example, if the accumulator has 5 leaves, x
and e
are
returned.
root
/ \
/ \
/ \
x o
/ \ / \
/ \ / \
o o o placeholder
/ \ / \ / \
a b c d e placeholder
sourcepub fn get_root_hash(reader: &R, num_leaves: LeafCount) -> Result<HashValue>
pub fn get_root_hash(reader: &R, num_leaves: LeafCount) -> Result<HashValue>
Get root hash at a specific version (hence num_leaves).
Auto Trait Implementations§
impl<R, H> RefUnwindSafe for MerkleAccumulator<R, H>where
H: RefUnwindSafe,
R: RefUnwindSafe,
impl<R, H> Send for MerkleAccumulator<R, H>
impl<R, H> Sync for MerkleAccumulator<R, H>
impl<R, H> Unpin for MerkleAccumulator<R, H>
impl<R, H> UnwindSafe for MerkleAccumulator<R, H>where
H: UnwindSafe,
R: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.