Compact state DB finished.

Closes #172
This commit is contained in:
Gav Wood 2016-01-18 14:44:06 +01:00
parent b9b08af518
commit 7b0e4af078
4 changed files with 11 additions and 6 deletions

View File

@ -117,7 +117,7 @@ impl Client {
let mut opts = Options::new();
opts.create_if_missing(true);
opts.set_max_open_files(256);
opts.set_use_fsync(false);
/*opts.set_use_fsync(false);
opts.set_bytes_per_sync(8388608);
opts.set_disable_data_sync(false);
opts.set_block_cache_size_mb(1024);
@ -132,7 +132,7 @@ impl Client {
opts.set_max_background_compactions(4);
opts.set_max_background_flushes(4);
opts.set_filter_deletes(false);
opts.set_disable_auto_compactions(true);
opts.set_disable_auto_compactions(false);*/
let mut state_path = path.to_path_buf();
state_path.push("state");
@ -207,7 +207,7 @@ impl Client {
return;
}
}
info!(target: "client", "Imported #{} ({})", header.number(), header.hash());
debug!(target: "client", "Imported #{} ({})", header.number(), header.hash());
}
}

View File

@ -471,7 +471,7 @@ impl ChainSync {
pub fn on_peer_aborting(&mut self, io: &mut SyncIo, peer: PeerId) {
trace!(target: "sync", "== Disconnecting {}", peer);
if self.peers.contains_key(&peer) {
info!(target: "sync", "Disconneced {}:{}", peer, io.peer_info(peer));
info!(target: "sync", "Disconnected {}:{}", peer, io.peer_info(peer));
self.clear_peer_download(peer);
self.peers.remove(&peer);
self.continue_sync(io);

View File

@ -100,6 +100,7 @@ impl JournalDB {
self.forward.remove(i);
}
try!(self.backing.delete(&last));
info!("JournalDB: delete journal for time #{}.{}, (canon was {}): {} entries", end_era, index, canon_id, to_remove.len());
index += 1;
}
}

View File

@ -71,6 +71,7 @@ impl OverlayDB {
/// ```
pub fn commit(&mut self) -> Result<u32, UtilError> {
let mut ret = 0u32;
let mut deletes = 0usize;
for i in self.overlay.drain().into_iter() {
let (key, (value, rc)) = i;
if rc != 0 {
@ -81,7 +82,7 @@ impl OverlayDB {
if total_rc < 0 {
return Err(From::from(BaseDataError::NegativelyReferencedHash));
}
self.put_payload(&key, (back_value, total_rc as u32));
deletes += if self.put_payload(&key, (back_value, total_rc as u32)) {1} else {0};
}
None => {
if rc < 0 {
@ -93,6 +94,7 @@ impl OverlayDB {
ret += 1;
}
}
info!("OverlayDB::commit() deleted {} nodes", deletes);
Ok(ret)
}
@ -130,14 +132,16 @@ impl OverlayDB {
}
/// Get the refs and value of the given key.
fn put_payload(&self, key: &H256, payload: (Bytes, u32)) {
fn put_payload(&self, key: &H256, payload: (Bytes, u32)) -> bool {
if payload.1 > 0 {
let mut s = RlpStream::new_list(2);
s.append(&payload.1);
s.append(&payload.0);
self.backing.put(&key.bytes(), &s.out()).expect("Low-level database error. Some issue with your hard disk?");
false
} else {
self.backing.delete(&key.bytes()).expect("Low-level database error. Some issue with your hard disk?");
true
}
}