Skip to content
Snippets Groups Projects
Commit 93facbf8 authored by Nikolay Volf's avatar Nikolay Volf Committed by Arkadiy Paronyan
Browse files

ethcore client config

parent 42f5d7f8
Tags
No related merge requests found
...@@ -38,7 +38,7 @@ use filter::Filter; ...@@ -38,7 +38,7 @@ use filter::Filter;
use log_entry::LocalizedLogEntry; use log_entry::LocalizedLogEntry;
use block_queue::{BlockQueue, BlockQueueInfo}; use block_queue::{BlockQueue, BlockQueueInfo};
use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute}; use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute};
use client::{BlockID, TransactionID, UncleID, TraceId, ClientConfig, BlockChainClient, MiningBlockChainClient, TraceFilter, CallAnalytics}; use client::{BlockID, TransactionID, UncleID, TraceId, ClientConfig, DatabaseCompactionProfile, BlockChainClient, MiningBlockChainClient, TraceFilter, CallAnalytics};
use client::Error as ClientError; use client::Error as ClientError;
use env_info::EnvInfo; use env_info::EnvInfo;
use executive::{Executive, Executed, TransactOptions, contract_address}; use executive::{Executive, Executed, TransactOptions, contract_address};
...@@ -146,10 +146,19 @@ impl<V> Client<V> where V: Verifier { ...@@ -146,10 +146,19 @@ impl<V> Client<V> where V: Verifier {
let chain = Arc::new(BlockChain::new(config.blockchain, &gb, &path)); let chain = Arc::new(BlockChain::new(config.blockchain, &gb, &path));
let tracedb = Arc::new(try!(TraceDB::new(config.tracing, &path, chain.clone()))); let tracedb = Arc::new(try!(TraceDB::new(config.tracing, &path, chain.clone())));
let mut state_db_config = match config.db_cache_size {
None => DatabaseConfig::default(),
Some(cache_size) => DatabaseConfig::with_cache(cache_size),
};
if config.db_compaction == DatabaseCompactionProfile::HDD {
state_db_config = state_db_config.compaction(CompactionProfile::hdd());
}
let mut state_db = journaldb::new( let mut state_db = journaldb::new(
&append_path(&path, "state"), &append_path(&path, "state"),
config.pruning, config.pruning,
config.db_cache_size); state_db_config);
if state_db.is_empty() && spec.ensure_db_good(state_db.as_hashdb_mut()) { if state_db.is_empty() && spec.ensure_db_good(state_db.as_hashdb_mut()) {
state_db.commit(0, &spec.genesis_header().hash(), None).expect("Error commiting genesis state to state DB"); state_db.commit(0, &spec.genesis_header().hash(), None).expect("Error commiting genesis state to state DB");
......
...@@ -20,6 +20,19 @@ pub use trace::{Config as TraceConfig, Switch}; ...@@ -20,6 +20,19 @@ pub use trace::{Config as TraceConfig, Switch};
pub use evm::VMType; pub use evm::VMType;
use util::journaldb; use util::journaldb;
/// Client state db compaction profile
#[derive(Debug, PartialEq)]
pub enum DatabaseCompactionProfile {
/// Default compaction profile
Default,
/// HDD or other slow storage io compaction profile
HDD,
}
impl Default for DatabaseCompactionProfile {
fn default() -> Self { DatabaseCompactionProfile::Default }
}
/// Client configuration. Includes configs for all sub-systems. /// Client configuration. Includes configs for all sub-systems.
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct ClientConfig { pub struct ClientConfig {
...@@ -37,4 +50,6 @@ pub struct ClientConfig { ...@@ -37,4 +50,6 @@ pub struct ClientConfig {
pub name: String, pub name: String,
/// State db cache-size if not default /// State db cache-size if not default
pub db_cache_size: Option<usize>, pub db_cache_size: Option<usize>,
/// State db compaction profile
pub db_compaction: DatabaseCompactionProfile,
} }
...@@ -23,7 +23,7 @@ mod test_client; ...@@ -23,7 +23,7 @@ mod test_client;
mod trace; mod trace;
pub use self::client::*; pub use self::client::*;
pub use self::config::{ClientConfig, BlockQueueConfig, BlockChainConfig, Switch, VMType}; pub use self::config::{ClientConfig, DatabaseCompactionProfile, BlockQueueConfig, BlockChainConfig, Switch, VMType};
pub use self::error::Error; pub use self::error::Error;
pub use types::ids::*; pub use types::ids::*;
pub use self::test_client::{TestBlockChainClient, EachBlockWith}; pub use self::test_client::{TestBlockChainClient, EachBlockWith};
...@@ -245,7 +245,7 @@ pub trait BlockChainClient : Sync + Send { ...@@ -245,7 +245,7 @@ pub trait BlockChainClient : Sync + Send {
} else { } else {
None None
} }
} }
} }
/// Extended client interface used for mining /// Extended client interface used for mining
......
...@@ -170,7 +170,13 @@ Footprint Options: ...@@ -170,7 +170,13 @@ Footprint Options:
--cache MEGABYTES Set total amount of discretionary memory to use for --cache MEGABYTES Set total amount of discretionary memory to use for
the entire system, overrides other cache and queue the entire system, overrides other cache and queue
options. options.
--db-cache-size MB Database cache size.
Database Options:
--db-cache-size MB Database cache size. Default if not specified.
--db-compaction TYPE Database compaction type. TYPE may be one of default, hdd
default - suitable for ssd backing storage/fast hdd
hdd - sutable for slow storage
[default: default].
Import/Export Options: Import/Export Options:
--from BLOCK Export from block BLOCK, which may be an index or --from BLOCK Export from block BLOCK, which may be an index or
...@@ -323,6 +329,7 @@ pub struct Args { ...@@ -323,6 +329,7 @@ pub struct Args {
pub flag_ipcpath: Option<String>, pub flag_ipcpath: Option<String>,
pub flag_ipcapi: Option<String>, pub flag_ipcapi: Option<String>,
pub flag_db_cache_size: Option<usize>, pub flag_db_cache_size: Option<usize>,
pub flag_db_compaction: String,
} }
pub fn print_version() { pub fn print_version() {
......
...@@ -278,6 +278,13 @@ impl Configuration { ...@@ -278,6 +278,13 @@ impl Configuration {
// forced state db cache size if provided // forced state db cache size if provided
client_config.db_cache_size = self.args.flag_db_cache_size.and_then(|cs| Some(cs / 4)); client_config.db_cache_size = self.args.flag_db_cache_size.and_then(|cs| Some(cs / 4));
// compaction profile
client_config.db_compaction_profile = match self.args.flag_db_compaction.as_str() {
"default" => DatabaseCompactionProfile::Default,
"hdd" => DatabaseCompactionProfile::HDD,
_ => { die!("Invalid compaction profile given (--db-compaction argument), expected hdd/default."); }
};
if self.args.flag_jitvm { if self.args.flag_jitvm {
client_config.vm_type = VMType::jit().unwrap_or_else(|| die!("Parity built without jit vm.")) client_config.vm_type = VMType::jit().unwrap_or_else(|| die!("Parity built without jit vm."))
} }
......
...@@ -72,7 +72,7 @@ impl CompactionProfile { ...@@ -72,7 +72,7 @@ impl CompactionProfile {
} }
/// Slow hdd compaction profile /// Slow hdd compaction profile
pub fn hdd(&self) -> CompactionProfile { pub fn hdd() -> CompactionProfile {
CompactionProfile { CompactionProfile {
initial_file_size: 192 * 1024 * 1024, initial_file_size: 192 * 1024 * 1024,
file_size_multiplier: 1, file_size_multiplier: 1,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment