paritytech / paritytech/trie

How to run a sample example?

Open
#175 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
274
Forks
72
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the failing call in src/main.rs and inspect the crate versions and APIs for RefTrieDBMut and RefTrieDB. Compare the example's imports and constructor usage with the currently exposed API. Done means the sample compiles and its assertions pass, or the example documents the correct way to run it.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.