Expand description
§vsdb_trie_db
An out-of-box wrapper of the
trie_db
crate.
This crate provides an out-of-the-box wrapper for trie-db
, based on the powerful vsdb
crate.
§Installation
Add this to your Cargo.toml
:
[dependencies]
vsdb_trie_db = "4.0"
§Usage
vsdb_trie_db
provides an out-of-the-box wrapper for the trie-db
crate, backed by vsdb
.
use vsdb_trie_db::MptStore;
// Create a new MptStore
let mut store = MptStore::new();
// Initialize a new trie with a backend key
let mut trie = store.trie_init(b"my_trie").unwrap();
// Insert a key-value pair
trie.insert(b"key1", b"value1").unwrap();
// Commit the changes to the trie
let mut trie = trie.commit().unwrap();
let root = trie.root();
// Retrieve the value
let value = trie.get(b"key1").unwrap().unwrap();
assert_eq!(value, b"value1");
// Create a read-only handle to the trie at a specific root
let ro_trie = trie.ro_handle(root).unwrap();
let value = ro_trie.get(b"key1").unwrap().unwrap();
assert_eq!(value, b"value1");
§License
This project is licensed under the MIT license.
Structs§
- MptOnce
- An owned, mutable Merkle Patricia Trie instance.
- MptRo
- A read-only Merkle Patricia Trie instance.
- MptStore
- A store for Merkle Patricia Tries (MPTs).
Traits§
- Value
EnDe - A trait for both encoding and decoding values.
Type Aliases§
- RawBytes
- A type alias for a vector of bytes, commonly used for raw data.
- RawKey
- A type alias for a raw key, represented as a vector of bytes.
- RawValue
- A type alias for a raw value, represented as a vector of bytes.
- Trie
Iter - An iterator over the items of a Merkle Patricia Trie.
- Trie
KeyIter - An iterator over the keys of a Merkle Patricia Trie.
- Trie
Root - The root hash of a Merkle Patricia Trie.