Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
journaldb changes (#10929)
Browse files Browse the repository at this point in the history
* inject_batch && commit_batch are no longer a part of journaldb

* get rid of redundant KeyedHashDB trait

* journaldb edition 2018

* journaldb trait moved to the lib.rs file

* making journaldb more idiomatic

* fix parity_bytes reexport

* rename parity-util-mem package in Cargo.toml file
  • Loading branch information
debris authored and dvdplm committed Aug 6, 2019
1 parent 7227985 commit 4695452
Show file tree
Hide file tree
Showing 10 changed files with 595 additions and 687 deletions.
19 changes: 1 addition & 18 deletions ethcore/account-state/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
//! should become general over time to the point where not even a
//! merkle trie is strictly necessary.
use std::collections::{HashMap, HashSet};
use std::collections::HashSet;
use std::sync::Arc;

use ethereum_types::{Address, H256};
use hash_db::{AsHashDB, EMPTY_PREFIX, HashDB, Prefix};
use kvdb::DBValue;
use memory_db::{HashKey, MemoryDB};
use parking_lot::Mutex;
use journaldb::AsKeyedHashDB;
use keccak_hasher::KeccakHasher;

use crate::account::Account;
Expand Down Expand Up @@ -90,10 +89,6 @@ impl ProofCheck {
}
}

impl journaldb::KeyedHashDB for ProofCheck {
fn keys(&self) -> HashMap<H256, i32> { self.0.keys() }
}

impl HashDB<KeccakHasher, DBValue> for ProofCheck {
fn get(&self, key: &H256, prefix: Prefix) -> Option<DBValue> {
self.0.get(key, prefix)
Expand Down Expand Up @@ -146,23 +141,11 @@ pub struct Proving<H> {
proof: Mutex<HashSet<DBValue>>,
}

impl<AH: AsKeyedHashDB + Send + Sync> AsKeyedHashDB for Proving<AH> {
fn as_keyed_hash_db(&self) -> &dyn journaldb::KeyedHashDB { self }
}

impl<AH: AsHashDB<KeccakHasher, DBValue> + Send + Sync> AsHashDB<KeccakHasher, DBValue> for Proving<AH> {
fn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue> { self }
fn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue> { self }
}

impl<H: AsKeyedHashDB + Send + Sync> journaldb::KeyedHashDB for Proving<H> {
fn keys(&self) -> HashMap<H256, i32> {
let mut keys = self.base.as_keyed_hash_db().keys();
keys.extend(self.changed.keys());
keys
}
}

impl<H: AsHashDB<KeccakHasher, DBValue> + Send + Sync> HashDB<KeccakHasher, DBValue> for Proving<H> {
fn get(&self, key: &H256, prefix: Prefix) -> Option<DBValue> {
match self.base.as_hash_db().get(key, prefix) {
Expand Down
3 changes: 2 additions & 1 deletion util/journaldb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ version = "0.2.0"
authors = ["Parity Technologies <[email protected]>"]
description = "A `HashDB` which can manage a short-term journal potentially containing many forks of mutually exclusive actions"
license = "GPL3"
edition = "2018"

[dependencies]
parity-bytes = "0.1"
ethereum-types = "0.6.0"
hash-db = "0.12.4"
parity-util-mem = "0.1"
malloc_size_of = { version = "0.1", package = "parity-util-mem" }
keccak-hasher = { path = "../keccak-hasher" }
kvdb = "0.1"
log = "0.4"
Expand Down
Loading

0 comments on commit 4695452

Please sign in to comment.