Struct arber::MerkleMountainRange [−][src]
pub struct MerkleMountainRange<T, S> where
T: Hashable + Clone,
S: Store<T>, { pub size: u64, // some fields omitted }
Expand description
Merkle-Mountain-Range (MMR) implementation.
All tree positions start at '1'
. MMR positions are depth-frist, post-order tree
traversal node positions and should not be seen as array indices.
The MMR Store
, however, is a flat list representation of the MMR, i.e. an array of
nodes. Hence, Store
elements are accessed using a '0'
based index.
Again, positions are '1'
based tree node positions, indices are '0'
based Store
locations.
Fields
size: u64
Total number of MMR nodes, i.e. MMR size
Implementations
impl<'a, T, S> MerkleMountainRange<T, S> where
T: Hashable + Clone,
S: Store<T>,
[src]
impl<'a, T, S> MerkleMountainRange<T, S> where
T: Hashable + Clone,
S: Store<T>,
[src]pub fn new(store: S) -> Self
[src]
pub fn append(&mut self, elem: &T) -> Result<u64, Error>
[src]
pub fn append(&mut self, elem: &T) -> Result<u64, Error>
[src]Append elem
to the MMR. Return new MMR size.
pub fn validate(&self) -> Result<bool, Error>
[src]
pub fn validate(&self) -> Result<bool, Error>
[src]Validate the MMR by re-calculating the hash of all inner, i.e. parent nodes.
Retrun true
, if the MMR is valid or an error.
pub fn proof(&self, pos: u64) -> Result<MerkleProof, Error>
[src]
pub fn proof(&self, pos: u64) -> Result<MerkleProof, Error>
[src]Return a MMR membership proof for a leaf node at position pos
.
pub fn hash(&self, pos: u64) -> Result<Hash, Error>
[src]
pub fn hash(&self, pos: u64) -> Result<Hash, Error>
[src]Return node hash at pos
.
Note that in case of an error, Error::Store
is returned and the error
message is referring to pss - 1
, i.e. an index.
Auto Trait Implementations
impl<T, S> RefUnwindSafe for MerkleMountainRange<T, S> where
S: RefUnwindSafe,
T: RefUnwindSafe,
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> Send for MerkleMountainRange<T, S> where
S: Send,
T: Send,
S: Send,
T: Send,
impl<T, S> Sync for MerkleMountainRange<T, S> where
S: Sync,
T: Sync,
S: Sync,
T: Sync,
impl<T, S> Unpin for MerkleMountainRange<T, S> where
S: Unpin,
T: Unpin,
S: Unpin,
T: Unpin,
impl<T, S> UnwindSafe for MerkleMountainRange<T, S> where
S: UnwindSafe,
T: UnwindSafe,
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self