store PMMRBackend

Implementation of the persistent Backend for the prunable MMR tree.

/// PMMR persistent backend implementation. Relies on multiple facilities to
/// handle writing, reading and pruning.
///
/// * A main storage file appends Hash instances as they come.
/// This AppendOnlyFile is also backed by a mmap for reads.
/// * An in-memory backend buffers the latest batch of writes to ensure the
/// PMMR can always read recent values even if they haven't been flushed to
/// disk yet.
/// * A leaf_set tracks unpruned (unremoved) leaf positions in the MMR..
/// * A prune_list tracks the positions of pruned (and compacted) roots in the
/// MMR.
pub struct PMMRBackend<T>
where
    T: PMMRable,
{
    data_dir: String,
    hash_file: AppendOnlyFile, // 两个文件之一
    data_file: AppendOnlyFile, // 两个文件之一
    leaf_set: LeafSet, // 未修剪数据
    prune_list: PruneList, // 已修剪数据
    _marker: marker::PhantomData<T>, // 临时存储。(自动操作)
}

不仅要实现 core pmmr 给出的 trait Backend,还要实现自身希望提供的功能,可以说任务艰巨。

和下面几个组件的关系:

PMMRBackend -> LeafSet -> Bitmap

PMMRBackend -> PruneList -> Bitmap

PMMRBackend -> DataFile -> AppendOnlyFile

results matching ""

    No results matching ""