vsdb_trie_db

Crates.iovsdb_trie_db
lib.rsvsdb_trie_db
version7.1.0
created_at2023-03-25 13:22:16.133523+00
updated_at2025-12-06 07:43:48.787972+00
descriptionA lightweight, production-grade Merkle Patricia Trie (MPT) implementation for vsdb
homepagehttps://github.com/rust-util-collections/vsdb
repositoryhttps://github.com/rust-util-collections/vsdb
max_upload_size
id820244
size60,545
中正 (haxjump)

documentation

README

vsdb_trie_db

Crates.io Docs.rs License Rust

An out-of-the-box wrapper for trie-db with persistent storage.

This crate provides MptStore, a high-level wrapper for trie-db that uses vsdb for its underlying storage. It simplifies the management of multiple Merkle Patricia Tries (MPTs), handling state, commits, and backend storage automatically.

Installation

Add this to your Cargo.toml:

[dependencies]
vsdb_trie_db = "6.0.1"

Usage

For more detailed API examples, see API Examples.

vsdb_trie_db provides an easy-to-use interface for creating and managing persistent MPTs.

use vsdb_trie_db::MptStore;

// Create a new MptStore
let store = MptStore::new();

// Initialize a new trie (starts with an empty root)
let mut trie = store.trie_init();

// Insert key-value pairs (automatically commits)
trie.insert(b"key1", b"value1").unwrap();
trie.insert(b"key2", b"value2").unwrap();

// Get the current root hash
let root = trie.root();

// Retrieve values
let value = trie.get(b"key1").unwrap().unwrap();
assert_eq!(value, b"value1");

// Load an existing trie from a root hash
let loaded_trie = store.trie_load(&root);
let value = loaded_trie.get(b"key1").unwrap().unwrap();
assert_eq!(value, b"value1");

// Batch update operations
let ops = vec![
    (b"key3".as_ref(), Some(b"value3".as_ref())),
    (b"key1".as_ref(), None), // Remove key1
];
trie.batch_update(&ops).unwrap();

License

This project is licensed under the MIT license.

Commit count: 382

cargo fmt