Type Definition patricia_trie_vapory::TrieDB[][src]

type TrieDB<'db> = TrieDB<'db, Layout>;

Convenience type alias to instantiate a Keccak/Rlp-flavoured TrieDB

Use it as a Trie trait object. You can use db() to get the backing database object. Use get and contains to query values associated with keys in the trie.

Example

extern crate tetsy_trie_db as trie;
extern crate patricia_trie_vapory as vaptrie;
extern crate tetsy_hash_db;
extern crate tetsy_keccak_hasher;
extern crate tetsy_memory_db;
extern crate vapory_types;
extern crate elastic_array;
extern crate journaldb;

use trie::*;
use tetsy_hash_db::*;
use tetsy_keccak_hasher::KeccakHasher;
use tetsy_memory_db::*;
use vapory_types::H256;
use vaptrie::{TrieDB, TrieDBMut};
use elastic_array::ElasticArray128;

type DBValue = ElasticArray128<u8>;

fn main() {
  let mut memdb = journaldb::new_tetsy_memory_db();
  let mut root = H256::zero();
  TrieDBMut::new(&mut memdb, &mut root).insert(b"foo", b"bar").unwrap();
  let t = TrieDB::new(&memdb, &root).unwrap();
  assert!(t.contains(b"foo").unwrap());
  assert_eq!(t.get(b"foo").unwrap().unwrap(), b"bar".to_vec());
}