diff --git a/src/cli.rs b/src/cli.rs index d64c73acd..45d4b63da 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -108,6 +108,12 @@ pub fn build_cli() -> App<'static, 'static> { .help("Listen to all WebSocket interfaces (default is local)") .takes_value(false), ) + .arg( + Arg::with_name("pruning") + .long("pruning") + .help("State Db PruningMode archiveall|archivecanonical|constrained (default is Constrained(256))") + .takes_value(true), + ) .subcommand(SubCommand::with_name("validator").about( "Enable validator mode", ).arg( diff --git a/src/client.rs b/src/client.rs index 92e50a7dc..8b15e3885 100644 --- a/src/client.rs +++ b/src/client.rs @@ -4,23 +4,23 @@ use std::path::PathBuf; use Arc; use client_db; -use state_db; use substrate_client; pub use chainx_api::{TBackend, TClient, TClientBlockBuilder, TExecutor}; use chainx_executor::NativeExecutor; use cli::ChainSpec; use state_machine::ExecutionStrategy; +use state_db::PruningMode; const FINALIZATION_WINDOW: u64 = 32; -pub fn build_client(db_path: &str, chainspec: ChainSpec) -> Arc { +pub fn build_client(db_path: &str, chainspec: ChainSpec, pruning: PruningMode) -> Arc { let backend = Arc::new( TBackend::new( client_db::DatabaseSettings { cache_size: None, path: PathBuf::from(db_path), - pruning: state_db::PruningMode::default(), + pruning: pruning, }, FINALIZATION_WINDOW, ) diff --git a/src/main.rs b/src/main.rs index 43f92b5dc..9d3c44245 100644 --- a/src/main.rs +++ b/src/main.rs @@ -82,6 +82,20 @@ fn main() { ChainSpec::Multi } }; + let pruning = match matches.value_of("pruning").unwrap_or("constrained") { + "archiveall" => { + info!("Pruning is ArchiveAll mode"); + state_db::PruningMode::ArchiveAll + } + "archivecanonical" => { + info!("Pruning is ArchiveCanonical mode"); + state_db::PruningMode::ArchiveCanonical + } + "constrained" | _ => { + info!("Pruning is Constrained mode"); + state_db::PruningMode::default() + } + }; let port = match matches.value_of("port") { Some(port) => port .parse() @@ -99,8 +113,8 @@ fn main() { ); let db_path = matches.value_of("db-path").unwrap_or("./.chainx"); - let client = client::build_client(db_path, chainspec); - + let client = client::build_client(db_path, chainspec, pruning); + let (exit_send, exit) = exit_future::signal(); let mut runtime = Runtime::new().expect("failed to start runtime on current thread"); let task_executor = runtime.executor();