Extract the hard dependency on rocksdb from the light client (#8034)
* Extract the hard dependency on rocksdb from the light client * Remove TODO
This commit is contained in:
@@ -27,11 +27,13 @@ use bytes::ToPretty;
|
||||
use rlp::PayloadInfo;
|
||||
use ethcore::service::ClientService;
|
||||
use ethcore::client::{Mode, DatabaseCompactionProfile, VMType, BlockImportError, BlockChainClient, BlockId};
|
||||
use ethcore::db::NUM_COLUMNS;
|
||||
use ethcore::error::ImportError;
|
||||
use ethcore::miner::Miner;
|
||||
use ethcore::verification::queue::VerifierSettings;
|
||||
use cache::CacheConfig;
|
||||
use informant::{Informant, FullNodeInformantData, MillisecondDuration};
|
||||
use kvdb_rocksdb::{Database, DatabaseConfig};
|
||||
use params::{SpecType, Pruning, Switch, tracing_switch_to_bool, fatdb_switch_to_bool};
|
||||
use helpers::{to_client_config, execute_upgrades};
|
||||
use dir::Directories;
|
||||
@@ -197,9 +199,6 @@ fn execute_import_light(cmd: ImportBlockchain) -> Result<(), String> {
|
||||
let mut config = LightClientConfig {
|
||||
queue: Default::default(),
|
||||
chain_column: ::ethcore::db::COL_LIGHT_CHAIN,
|
||||
db_cache_size: Some(cmd.cache_config.blockchain() as usize * 1024 * 1024),
|
||||
db_compaction: compaction,
|
||||
db_wal: cmd.wal,
|
||||
verify_full: true,
|
||||
check_seal: cmd.check_seal,
|
||||
};
|
||||
@@ -207,9 +206,24 @@ fn execute_import_light(cmd: ImportBlockchain) -> Result<(), String> {
|
||||
config.queue.max_mem_use = cmd.cache_config.queue() as usize * 1024 * 1024;
|
||||
config.queue.verifier_settings = cmd.verifier_settings;
|
||||
|
||||
// initialize database.
|
||||
let db = {
|
||||
let db_config = DatabaseConfig {
|
||||
memory_budget: Some(cmd.cache_config.blockchain() as usize * 1024 * 1024),
|
||||
compaction: compaction,
|
||||
wal: cmd.wal,
|
||||
.. DatabaseConfig::with_columns(NUM_COLUMNS)
|
||||
};
|
||||
|
||||
Arc::new(Database::open(
|
||||
&db_config,
|
||||
&client_path.to_str().expect("DB path could not be converted to string.")
|
||||
).map_err(|e| format!("Failed to open database: {}", e))?)
|
||||
};
|
||||
|
||||
// TODO: could epoch signals be avilable at the end of the file?
|
||||
let fetch = ::light::client::fetch::unavailable();
|
||||
let service = LightClientService::start(config, &spec, fetch, &client_path, cache)
|
||||
let service = LightClientService::start(config, &spec, fetch, db, cache)
|
||||
.map_err(|e| format!("Failed to start client: {}", e))?;
|
||||
|
||||
// free up the spec in memory.
|
||||
|
||||
@@ -24,6 +24,7 @@ use ansi_term::Colour;
|
||||
use ctrlc::CtrlC;
|
||||
use ethcore::account_provider::{AccountProvider, AccountProviderSettings};
|
||||
use ethcore::client::{Client, Mode, DatabaseCompactionProfile, VMType, BlockChainClient};
|
||||
use ethcore::db::NUM_COLUMNS;
|
||||
use ethcore::ethstore::ethkey;
|
||||
use ethcore::miner::{Miner, MinerService, MinerOptions};
|
||||
use ethcore::miner::{StratumOptions, Stratum};
|
||||
@@ -38,6 +39,7 @@ use hash_fetch::fetch::{Fetch, Client as FetchClient};
|
||||
use hash_fetch;
|
||||
use informant::{Informant, LightNodeInformantData, FullNodeInformantData};
|
||||
use journaldb::Algorithm;
|
||||
use kvdb_rocksdb::{Database, DatabaseConfig};
|
||||
use light::Cache as LightDataCache;
|
||||
use miner::external::ExternalMiner;
|
||||
use node_filter::NodeFilter;
|
||||
@@ -222,9 +224,6 @@ fn execute_light_impl(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger
|
||||
let mut config = light_client::Config {
|
||||
queue: Default::default(),
|
||||
chain_column: ::ethcore::db::COL_LIGHT_CHAIN,
|
||||
db_cache_size: Some(cmd.cache_config.blockchain() as usize * 1024 * 1024),
|
||||
db_compaction: compaction,
|
||||
db_wal: cmd.wal,
|
||||
verify_full: true,
|
||||
check_seal: cmd.check_seal,
|
||||
};
|
||||
@@ -241,7 +240,22 @@ fn execute_light_impl(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger
|
||||
sync: sync_handle.clone(),
|
||||
};
|
||||
|
||||
let service = light_client::Service::start(config, &spec, fetch, &db_dirs.client_path(algorithm), cache.clone())
|
||||
// initialize database.
|
||||
let db = {
|
||||
let db_config = DatabaseConfig {
|
||||
memory_budget: Some(cmd.cache_config.blockchain() as usize * 1024 * 1024),
|
||||
compaction: compaction,
|
||||
wal: cmd.wal,
|
||||
.. DatabaseConfig::with_columns(NUM_COLUMNS)
|
||||
};
|
||||
|
||||
Arc::new(Database::open(
|
||||
&db_config,
|
||||
&db_dirs.client_path(algorithm).to_str().expect("DB path could not be converted to string.")
|
||||
).map_err(|e| format!("Error opening database: {}", e))?)
|
||||
};
|
||||
|
||||
let service = light_client::Service::start(config, &spec, fetch, db, cache.clone())
|
||||
.map_err(|e| format!("Error starting light client: {}", e))?;
|
||||
let client = service.client();
|
||||
let txq = Arc::new(RwLock::new(::light::transaction_queue::TransactionQueue::default()));
|
||||
|
||||
Reference in New Issue
Block a user