paritytech / paritytech/trie

Consider changing MemoryDB::new to take no arguments

Open
#29 0 comments 0 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

See https://github.com/paritytech/substrate/issues/1427. MemoryDB is different from a lot of Rust storage types in that the new function takes an argument. I think it would make more sense for MemoryDB::new to construct an empty DB, alike, MemoryDB::default. A new from_data function could be added that replaces the old new function:

pub fn from_data(data: &'a [u8]) -> Self {
    Self::from_null_node(data, data.into())
}

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 by locating the MemoryDB::new entry point and its callers, then compare its current behavior with MemoryDB::default. Check how the proposed from_data API would preserve existing construction behavior; the work is done when the empty constructor and data-based constructor are both available without breaking callers.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.