using background writes
This commit is contained in:
parent
1065541453
commit
4d178961f2
|
@ -49,4 +49,8 @@ pub trait BlockStapler {
|
||||||
|
|
||||||
/// insert pre-processed block in the storage
|
/// insert pre-processed block in the storage
|
||||||
fn insert_indexed_block(&self, block: &IndexedBlock) -> Result<BlockInsertedChain, Error>;
|
fn insert_indexed_block(&self, block: &IndexedBlock) -> Result<BlockInsertedChain, Error>;
|
||||||
|
|
||||||
|
/// flushes the underlined store (if applicable)
|
||||||
|
fn flush(&self);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -464,6 +464,7 @@ impl Storage {
|
||||||
.map(|header| header.bits.to_f64())
|
.map(|header| header.bits.to_f64())
|
||||||
.unwrap_or(1.0f64)
|
.unwrap_or(1.0f64)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BlockHeaderProvider for Storage {
|
impl BlockHeaderProvider for Storage {
|
||||||
|
@ -680,6 +681,10 @@ impl BlockStapler for Storage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn flush(&self) {
|
||||||
|
self.database.flush().expect("Failed to flush database. Out of disk space?");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TransactionProvider for Storage {
|
impl TransactionProvider for Storage {
|
||||||
|
|
|
@ -170,6 +170,9 @@ impl BlockStapler for TestStorage {
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn flush(&self) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TransactionProvider for TestStorage {
|
impl TransactionProvider for TestStorage {
|
||||||
|
|
|
@ -28,7 +28,7 @@ impl UpdateContext {
|
||||||
self.db_transaction.put(Some(COL_TRANSACTIONS_META), &*hash, &meta.into_bytes());
|
self.db_transaction.put(Some(COL_TRANSACTIONS_META), &*hash, &meta.into_bytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
try!(db.write(self.db_transaction));
|
db.write_buffered(self.db_transaction);
|
||||||
|
|
||||||
trace!("Applied transaction for block {:?}", &self.target.to_reversed_str());
|
trace!("Applied transaction for block {:?}", &self.target.to_reversed_str());
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -318,6 +318,7 @@ impl ChainVerifier {
|
||||||
for task in transaction_tasks.iter_mut() {
|
for task in transaction_tasks.iter_mut() {
|
||||||
scope.execute(move || task.progress(self))
|
scope.execute(move || task.progress(self))
|
||||||
}
|
}
|
||||||
|
self.store.flush();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue