Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run a sample example? #175

Open
arunpatro opened this issue Dec 14, 2022 · 1 comment
Open

How to run a sample example? #175

arunpatro opened this issue Dec 14, 2022 · 1 comment

Comments

@arunpatro
Copy link

I am unable to execute this test:

use hash_db::Hasher;
use reference_trie::{RefTrieDBMut, RefTrieDB};
use trie_db::DBValue;
use keccak_hasher::KeccakHasher;
use memory_db::*;

fn main() {
    let mut memdb = MemoryDB::<KeccakHasher, HashKey<_>, _>::default();
    let mut root = Default::default();
    RefTrieDBMut::new(&mut memdb, &mut root).insert(b"foo", b"bar").unwrap();
    let t = RefTrieDB::new(&memdb, &root);
    assert!(t.contains(b"foo").unwrap());
    assert_eq!(t.get(b"foo").unwrap().unwrap(), b"bar".to_vec());
}

But I get this error:

 --> src/main.rs:10:19
   |
10 |     RefTrieDBMut::new(&mut memdb, &mut root).insert(b"foo", b"bar").unwrap();
   |                   ^^^ function or associated item not found in `trie_db::triedbmut::TrieDBMut<'_, ExtensionLayout>`

And Indeed trie_db::triedbmut::TrieDBMut doesn't have a new method. Any help?

@dimartiro
Copy link
Contributor

@arunpatro could you solve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants