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

JournalDB with in-memory overlay (option2) #634

Merged
merged 10 commits into from
Mar 12, 2016
9 changes: 3 additions & 6 deletions ethcore/src/account_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ pub struct AccountDB<'db> {

#[inline]
fn combine_key<'a>(address: &'a H256, key: &'a H256) -> H256 {
let mut addr_hash = address.sha3();
// preserve 96 bits of original key for db lookup
addr_hash[0..12].clone_from_slice(&[0u8; 12]);
&addr_hash ^ key
address ^ key
}

impl<'db> AccountDB<'db> {
pub fn new(db: &'db HashDB, address: &Address) -> AccountDB<'db> {
AccountDB {
db: db,
address: x!(address.clone()),
address: x!(address),
}
}
}
Expand Down Expand Up @@ -70,7 +67,7 @@ impl<'db> AccountDBMut<'db> {
pub fn new(db: &'db mut HashDB, address: &Address) -> AccountDBMut<'db> {
AccountDBMut {
db: db,
address: x!(address.clone()),
address: x!(address),
}
}

Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub struct Client<V = CanonVerifier> where V: Verifier {
}

const HISTORY: u64 = 1000;
const CLIENT_DB_VER_STR: &'static str = "5.1";
const CLIENT_DB_VER_STR: &'static str = "5.2";

impl Client<CanonVerifier> {
/// Create a new client with given spec and DB path.
Expand Down
5 changes: 2 additions & 3 deletions parity/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ Protocol Options:
--testnet Equivalent to --chain testnet (geth-compatible).
--networkid INDEX Override the network identifier from the chain we are on.
--pruning METHOD Configure pruning of the state/storage trie. METHOD may be one of: archive,
light (experimental) [default: archive].
light (experimental), fast (experimental) [default: archive].
-d --datadir PATH Specify the database & configuration directory path [default: $HOME/.parity]
--db-path PATH Specify the database & configuration directory path [default: $HOME/.parity]
--pruning Client should prune the state/storage trie.
--keys-path PATH Specify the path for JSON key files to be found [default: $HOME/.web3/keys]
--identity NAME Specify your node's name.

Expand Down Expand Up @@ -425,7 +424,7 @@ impl Configuration {
"" => journaldb::Algorithm::Archive,
"archive" => journaldb::Algorithm::Archive,
"pruned" => journaldb::Algorithm::EarlyMerge,
// "fast" => journaldb::Algorithm::OverlayRecent, // TODO: @arkpar uncomment this once option 2 is merged.
"fast" => journaldb::Algorithm::OverlayRecent,
// "slow" => journaldb::Algorithm::RefCounted, // TODO: @gavofyork uncomment this once ref-count algo is merged.
_ => { die!("Invalid pruning method given."); }
};
Expand Down
2 changes: 1 addition & 1 deletion util/src/journaldb/archivedb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ mod tests {
fn reopen_fork() {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let (foo, bar, baz) = {
let (foo, _, _) = {
let mut jdb = ArchiveDB::new(dir.to_str().unwrap());
// history is 1
let foo = jdb.insert(b"foo");
Expand Down
2 changes: 2 additions & 0 deletions util/src/journaldb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use common::*;
pub mod traits;
mod archivedb;
mod optiononedb;
mod overlay;

/// Export the JournalDB trait.
pub use self::traits::JournalDB;
Expand Down Expand Up @@ -73,6 +74,7 @@ pub fn new(path: &str, algorithm: Algorithm) -> Box<JournalDB> {
match algorithm {
Algorithm::Archive => Box::new(archivedb::ArchiveDB::new(path)),
Algorithm::EarlyMerge => Box::new(optiononedb::OptionOneDB::new(path)),
Algorithm::OverlayRecent => Box::new(overlay::JournalOverlayDB::new(path)),
_ => unimplemented!(),
}
}
Loading