pub struct VerMapWithProof<K, V, T: TrieCalc> { /* private fields */ }Expand description
A versioned key-value map with Merkle root hash computation.
Wraps a VerMap<K, V> and a TrieCalc back-end T to provide
a merkle_root method that lazily computes
the 32-byte Merkle root hash for any branch or commit.
§Incremental updates
The internal trie tracks a sync point — the commit it was last
synchronized to. When merkle_root is called:
- If the trie is already synced to the target → return cached hash.
- If the target is reachable via diff from the sync point → apply diff incrementally.
- Otherwise → full rebuild from the store’s iterator.
§Automatic cache lifecycle
The in-memory trie is transparently cached to disk so that process restarts only require an incremental diff rather than a full rebuild.
- Auto-load — when created via
neworfrom_map, the constructor silently attempts to restore a previous cache file. On miss or corruption it falls back to a full rebuild on the nextmerkle_rootcall. - Auto-save — the committed trie state is persisted eagerly
inside
merkle_root(specifically, aftersync_to_commitcompletes). Errors are silently ignored because the cache is disposable: the authoritative data lives in the underlyingVerMap.
No manual save_cache / load_cache calls are needed.
Implementations§
Source§impl<K, V, T> VerMapWithProof<K, V, T>
impl<K, V, T> VerMapWithProof<K, V, T>
Sourcepub fn from_map(map: VerMap<K, V>) -> Self
pub fn from_map(map: VerMap<K, V>) -> Self
Wraps an existing VerMap.
Runs gc for crash recovery (if needed) and
B+ tree cleanup, then attempts to restore the trie cache.
Sourcepub fn map_mut(&mut self) -> &mut VerMap<K, V>
pub fn map_mut(&mut self) -> &mut VerMap<K, V>
Returns a mutable reference to the underlying VerMap.
Mutations through this reference will not automatically
update the trie — call merkle_root to
resynchronize.