Review remarks resolved.

This commit is contained in:
Gav Wood 2016-03-04 22:54:59 +01:00
parent bc018faedc
commit 559e01ea84
3 changed files with 20 additions and 10 deletions

View File

@ -76,12 +76,24 @@ pub enum BlockStatus {
}
/// Client configuration. Includes configs for all sub-systems.
#[derive(Debug, Default)]
#[derive(Debug)]
pub struct ClientConfig {
/// Block queue configuration.
pub queue: BlockQueueConfig,
/// Blockchain configuration.
pub blockchain: BlockChainConfig,
/// Prefer journal rather than archive.
pub prefer_journal: bool,
}
impl Default for ClientConfig {
fn default() -> ClientConfig {
ClientConfig {
queue: Default::default(),
blockchain: Default::default(),
prefer_journal: false,
}
}
}
/// Information about the blockchain gathered together.
@ -212,8 +224,7 @@ 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, if config.blockchain.prefer_journal { "" } else { "-archive" }));
let pj = config.blockchain.prefer_journal;
dir.push(format!("v{}-sec-{}", CLIENT_DB_VER_STR, if config.prefer_journal { "pruned" } else { "archive" }));
let path = dir.as_path();
let gb = spec.genesis_block();
let chain = Arc::new(RwLock::new(BlockChain::new(config.blockchain, &gb, path)));
@ -221,7 +232,7 @@ impl Client {
state_path.push("state");
let engine = Arc::new(try!(spec.to_engine()));
let mut state_db = JournalDB::from_prefs(state_path.to_str().unwrap(), pj);
let mut state_db = JournalDB::from_prefs(state_path.to_str().unwrap(), config.prefer_journal);
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");
}

View File

@ -313,7 +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.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();

View File

@ -147,7 +147,6 @@ impl JournalDB {
let (ret, _) = Self::batch_overlay_insertions(&mut self.overlay, &batch);
try!(self.backing.write(batch));
Ok(ret as u32)
}
/// Commit all recent insert operations and historical removals from the old era
@ -177,7 +176,7 @@ impl JournalDB {
// and the key is safe to delete.
// record new commit's details.
debug!("commit: #{} ({}), end era: {:?}", now, id, end);
trace!("commit: #{} ({}), end era: {:?}", now, id, end);
let mut counters = self.counters.as_ref().unwrap().write().unwrap();
let batch = DBTransaction::new();
{
@ -248,14 +247,14 @@ impl JournalDB {
try!(batch.delete(&h));
deletes += 1;
}
debug!("commit: Delete journal for time #{}.{}, (canon was {}): {} entries", end_era, index, canon_id, deletes);
trace!("commit: Delete journal for time #{}.{}, (canon was {}): {} entries", end_era, index, canon_id, deletes);
}
// Commit overlay insertions
let (ret, deletes) = Self::batch_overlay_insertions(&mut self.overlay, &batch);
try!(self.backing.write(batch));
debug!("commit: Deleted {} nodes", deletes);
trace!("commit: Deleted {} nodes", deletes);
Ok(ret as u32)
}
@ -304,7 +303,7 @@ impl JournalDB {
era -= 1;
}
}
debug!("Recovered {} counters", res.len());
trace!("Recovered {} counters", res.len());
res
}
}