ethcore client config
This commit is contained in:
parent
42f5d7f897
commit
93facbf854
@ -38,7 +38,7 @@ use filter::Filter;
|
||||
use log_entry::LocalizedLogEntry;
|
||||
use block_queue::{BlockQueue, BlockQueueInfo};
|
||||
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 env_info::EnvInfo;
|
||||
use executive::{Executive, Executed, TransactOptions, contract_address};
|
||||
@ -146,10 +146,19 @@ impl<V> Client<V> where V: Verifier {
|
||||
let chain = Arc::new(BlockChain::new(config.blockchain, &gb, &path));
|
||||
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(
|
||||
&append_path(&path, "state"),
|
||||
config.pruning,
|
||||
config.db_cache_size);
|
||||
state_db_config);
|
||||
|
||||
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");
|
||||
|
@ -20,6 +20,19 @@ pub use trace::{Config as TraceConfig, Switch};
|
||||
pub use evm::VMType;
|
||||
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.
|
||||
#[derive(Debug, Default)]
|
||||
pub struct ClientConfig {
|
||||
@ -37,4 +50,6 @@ pub struct ClientConfig {
|
||||
pub name: String,
|
||||
/// State db cache-size if not default
|
||||
pub db_cache_size: Option<usize>,
|
||||
/// State db compaction profile
|
||||
pub db_compaction: DatabaseCompactionProfile,
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ mod test_client;
|
||||
mod trace;
|
||||
|
||||
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 types::ids::*;
|
||||
pub use self::test_client::{TestBlockChainClient, EachBlockWith};
|
||||
@ -245,7 +245,7 @@ pub trait BlockChainClient : Sync + Send {
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Extended client interface used for mining
|
||||
|
@ -170,7 +170,13 @@ Footprint Options:
|
||||
--cache MEGABYTES Set total amount of discretionary memory to use for
|
||||
the entire system, overrides other cache and queue
|
||||
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:
|
||||
--from BLOCK Export from block BLOCK, which may be an index or
|
||||
@ -323,6 +329,7 @@ pub struct Args {
|
||||
pub flag_ipcpath: Option<String>,
|
||||
pub flag_ipcapi: Option<String>,
|
||||
pub flag_db_cache_size: Option<usize>,
|
||||
pub flag_db_compaction: String,
|
||||
}
|
||||
|
||||
pub fn print_version() {
|
||||
|
@ -278,6 +278,13 @@ impl Configuration {
|
||||
// forced state db cache size if provided
|
||||
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 {
|
||||
client_config.vm_type = VMType::jit().unwrap_or_else(|| die!("Parity built without jit vm."))
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ impl CompactionProfile {
|
||||
}
|
||||
|
||||
/// Slow hdd compaction profile
|
||||
pub fn hdd(&self) -> CompactionProfile {
|
||||
pub fn hdd() -> CompactionProfile {
|
||||
CompactionProfile {
|
||||
initial_file_size: 192 * 1024 * 1024,
|
||||
file_size_multiplier: 1,
|
||||
|
Loading…
Reference in New Issue
Block a user