CleanAuthenticatedBitMap

Type Alias CleanAuthenticatedBitMap 

Source
pub type CleanAuthenticatedBitMap<D, const N: usize> = BitMap<D, N, Clean<D>>;
Expand description

A bitmap in the clean state (root has been computed).

Aliased Type§

pub struct CleanAuthenticatedBitMap<D, const N: usize> { /* private fields */ }

Implementations§

Source§

impl<D: Digest, const N: usize> CleanBitMap<D, N>

Source

pub fn new(hasher: &mut impl Hasher<D>, pool: Option<ThreadPool>) -> Self

Return a new empty bitmap.

Source

pub fn get_node(&self, position: Position) -> Option<D>

Source

pub async fn restore_pruned<C: RStorage + Metrics + Clock>( context: C, partition: &str, pool: Option<ThreadPool>, hasher: &mut impl Hasher<D>, ) -> Result<Self, Error>

Restore the fully pruned state of a bitmap from the metadata in the given partition. (The caller must still replay retained elements to restore its full state.)

The metadata must store the number of pruned chunks and the pinned digests corresponding to that pruning boundary.

Returns an error if the bitmap could not be restored, e.g. because of data corruption or underlying storage error.

Source

pub async fn write_pruned<C: RStorage + Metrics + Clock>( &self, context: C, partition: &str, ) -> Result<(), Error>

Write the information necessary to restore the bitmap in its fully pruned state at its last pruning boundary. Restoring the entire bitmap state is then possible by replaying the retained elements.

Source

pub fn prune_to_bit(&mut self, bit: u64) -> Result<(), Error>

Prune all complete chunks before the chunk containing the given bit.

The chunk containing bit and all subsequent chunks are retained. All chunks before it are pruned from the bitmap and the underlying MMR.

If bit equals the bitmap length, this prunes all complete chunks while retaining the empty trailing chunk, preparing the bitmap for appending new data.

Source

pub const fn root(&self) -> D

Return the cached root digest against which inclusion proofs can be verified.

§Format

The root digest is simply that of the underlying MMR whenever the bit count falls on a chunk boundary. Otherwise, the root is computed as follows in order to capture the bits that are not yet part of the MMR:

hash(mmr_root || next_bit as u64 be_bytes || last_chunk_digest)

The root is computed during merkleization and cached, so this method is cheap to call.

Source

pub async fn proof( &self, hasher: &mut impl Hasher<D>, bit: u64, ) -> Result<(Proof<D>, [u8; N]), Error>

Return an inclusion proof for the specified bit, along with the chunk of the bitmap containing that bit. The proof can be used to prove any bit in the chunk.

The bitmap proof stores the number of bits in the bitmap within the size field of the proof instead of MMR size since the underlying MMR’s size does not reflect the number of bits in any partial chunk. The underlying MMR size can be derived from the number of bits as leaf_num_to_pos(proof.size / BitMap<_, N>::CHUNK_SIZE_BITS).

§Errors

Returns Error::BitOutOfBounds if bit is out of bounds.

Source

pub fn into_dirty(self) -> DirtyBitMap<D, N>

Convert this clean bitmap into a dirty bitmap without making any changes to it.

Trait Implementations§

Source§

impl<D: Digest, const N: usize> Storage<D> for CleanBitMap<D, N>

Source§

fn size(&self) -> Position

Return the number of elements in the MMR.
Source§

async fn get_node(&self, position: Position) -> Result<Option<D>, Error>

Return the specified node of the MMR if it exists & hasn’t been pruned.