From bbbaffbc531571894b34f5c5a0de1e7eda453c60 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 4 Mar 2016 21:06:28 +0100 Subject: [PATCH] "--archive" option for disabling the journal DB Fixes #579 --- ethcore/src/blockchain/blockchain.rs | 3 +++ ethcore/src/client.rs | 5 +++-- parity/main.rs | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ethcore/src/blockchain/blockchain.rs b/ethcore/src/blockchain/blockchain.rs index f412a8240..e79f1668c 100644 --- a/ethcore/src/blockchain/blockchain.rs +++ b/ethcore/src/blockchain/blockchain.rs @@ -40,6 +40,8 @@ pub struct BlockChainConfig { pub pref_cache_size: usize, /// Maximum cache size in bytes. pub max_cache_size: usize, + /// Prefer journal rather than archive. + pub prefer_journal: bool, } impl Default for BlockChainConfig { @@ -47,6 +49,7 @@ impl Default for BlockChainConfig { BlockChainConfig { pref_cache_size: 1 << 14, max_cache_size: 1 << 20, + prefer_journal: false, } } } diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index 422f1eaa2..87f2c9e96 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -212,7 +212,8 @@ impl Client { let mut dir = path.to_path_buf(); dir.push(H64::from(spec.genesis_header().hash()).hex()); //TODO: sec/fat: pruned/full versioning - dir.push(format!("v{}-sec-pruned", CLIENT_DB_VER_STR)); + dir.push(format!("v{}-sec-pruned-{}", CLIENT_DB_VER_STR, if config.blockchain.prefer_journal { "journal" } else { "archive" })); + let pj = config.blockchain.prefer_journal; let path = dir.as_path(); let gb = spec.genesis_block(); let chain = Arc::new(RwLock::new(BlockChain::new(config.blockchain, &gb, path))); @@ -220,7 +221,7 @@ impl Client { state_path.push("state"); let engine = Arc::new(try!(spec.to_engine())); - let mut state_db = JournalDB::new(state_path.to_str().unwrap()); + let mut state_db = JournalDB::from_prefs(state_path.to_str().unwrap(), pj); if state_db.is_empty() && engine.spec().ensure_db_good(&mut state_db) { state_db.commit(0, &engine.spec().genesis_header().hash(), None).expect("Error commiting genesis state to state DB"); } diff --git a/parity/main.rs b/parity/main.rs index b991f36cd..f1a11229f 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -65,6 +65,7 @@ Usage: Options: --chain CHAIN Specify the blockchain type. CHAIN may be either a JSON chain specification file or frontier, mainnet, morden, or testnet [default: frontier]. + --archive Client should not prune the state/storage trie. -d --db-path PATH Specify the database & configuration directory path [default: $HOME/.parity] --keys-path PATH Specify the path for JSON key files to be found [default: $HOME/.web3/keys] @@ -102,6 +103,7 @@ struct Args { flag_chain: String, flag_db_path: String, flag_keys_path: String, + flag_archive: bool, flag_no_bootstrap: bool, flag_listen_address: String, flag_public_address: Option, @@ -311,6 +313,7 @@ impl Configuration { let mut client_config = ClientConfig::default(); client_config.blockchain.pref_cache_size = self.args.flag_cache_pref_size; client_config.blockchain.max_cache_size = self.args.flag_cache_max_size; + client_config.blockchain.prefer_journal = !self.args.flag_archive; client_config.queue.max_mem_use = self.args.flag_queue_max_size; let mut service = ClientService::start(client_config, spec, net_settings, &Path::new(&self.path())).unwrap(); let client = service.client().clone();