Struct tari_mmr::MmrCache[][src]

pub struct MmrCache<D, BaseBackend, CpBackend> where
    D: Digest,
    BaseBackend: ArrayLike<Value = Hash>, 
{ pub curr_mmr: PrunedMutableMmr<D>, // some fields omitted }
Expand description

The MMR cache is used to calculate Merkle and Merklish roots based on the state of the set of shared checkpoints. It can efficiently create an updated cache state when small checkpoint rewinds were detected or the checkpoint state has been expanded.

Fields

curr_mmr: PrunedMutableMmr<D>

Implementations

Creates a new MMR cache with access to the provided set of shared checkpoints.

Inform the MmrCache that the first N checkpoints have been merged to allow the base and current indices to be updated.

This function updates the state of the MMR cache based on the current state of the shared checkpoints.

Reset the MmrCache and rebuild the base and current MMR state.

Returns the hash of the leaf index provided, as well as its deletion status. The node has been marked for deletion if the boolean value is true.

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

Methods from Deref<Target = PrunedMutableMmr<D>>

Return the number of leaf nodes in the MutableMmr that have not been marked as deleted.

NB: This is semantically different to MerkleMountainRange::len(). The latter returns the total number of nodes in the MMR, while this function returns the number of leaf nodes minus the number of nodes marked for deletion.

Returns true if the the MMR contains no nodes, OR all nodes have been marked for deletion

This function returns the hash of the leaf index provided, indexed from 0. If the hash does not exist, or if it has been marked for deletion, None is returned.

Returns the hash of the leaf index provided, as well as its deletion status. The node has been marked for deletion if the boolean value is true.

Returns the number of leaf nodes in the MMR.

Returns a merkle(ish) root for this merkle set.

The root is calculated by concatenating the MMR merkle root with the compressed serialisation of the bitmap and then hashing the result.

Returns only the MMR merkle root without the compressed serialisation of the bitmap

Walks the nodes in the MMR and validates all parent hashes

This just calls through to the underlying MMR’s validate method. There’s nothing we can do to check whether the roaring bitmap represents all the leaf nodes that we want to delete. Note: A struct that uses MutableMmr and links it to actual data should be able to do this though.

Returns the state of the MMR that consists of the leaf hashes and the deleted nodes.

Expose the MerkleMountainRange for verifying proofs

Return a reference to the bitmap of deleted nodes

Trait Implementations

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

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.