Struct tari_mmr::MerkleMountainRange[][src]

pub struct MerkleMountainRange<D, B> { /* fields omitted */ }
Expand description

An implementation of a Merkle Mountain Range (MMR). The MMR is append-only and immutable. Only the hashes are stored in this data structure. The data itself can be stored anywhere as long as you can maintain a 1:1 mapping of the hash of that data to the leaf nodes in the MMR.

Implementations

Create a new Merkle mountain range using the given backend for storage

Clears the MMR and assigns its state from the list of leaf hashes given in leaf_hashes.

Clears the MMR and assigns its state from the provided iterator, which must produce a finite number of Hashes.

Return the number of nodes in the full Merkle Mountain range, excluding bagged hashes

Returns true if the MMR contains no hashes

This function returns the hash of the node index provided indexed from 0

Returns the number of leaf nodes in the MMR.

This function returns the hash of the leaf index provided, indexed from 0

Returns a set of leaf hashes from the MMR.

This function will return the single merkle root of the MMR by simply hashing the peaks together.

Note that this differs from the bagging strategy used in other MMR implementations, and saves you a few hashes

Push a new element into the MMR. Computes new related peaks at the same time if applicable. Returns the new length of the merkle mountain range (the number of all nodes, not just leaf nodes).

Walks the nodes in the MMR and revalidates all parent hashes

Search for the node index of the given hash in the MMR. This is a very slow function, being O(n). In general, it’s better to cache the index of the hash when storing it rather than using this function, but it’s here for completeness.

Search for the leaf index of the given hash in the leaf nodes of the MMR.

Trait Implementations

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.