| Crates.io | vsdb_trie_db |
| lib.rs | vsdb_trie_db |
| version | 7.1.0 |
| created_at | 2023-03-25 13:22:16.133523+00 |
| updated_at | 2025-12-06 07:43:48.787972+00 |
| description | A lightweight, production-grade Merkle Patricia Trie (MPT) implementation for vsdb |
| homepage | https://github.com/rust-util-collections/vsdb |
| repository | https://github.com/rust-util-collections/vsdb |
| max_upload_size | |
| id | 820244 |
| size | 60,545 |
An out-of-the-box wrapper for
trie-dbwith 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.
Add this to your Cargo.toml:
[dependencies]
vsdb_trie_db = "6.0.1"
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();
This project is licensed under the MIT license.