Trait journaldb::JournalDB [−][src]
pub trait JournalDB: HashDB<KeccakHasher> { fn boxed_clone(&self) -> Box<JournalDB>; fn mem_used(&self) -> usize; fn is_empty(&self) -> bool; fn latest_era(&self) -> Option<u64>; fn journal_under(
&mut self,
batch: &mut DBTransaction,
now: u64,
id: &H256
) -> Result<u32>; fn mark_canonical(
&mut self,
batch: &mut DBTransaction,
era: u64,
id: &H256
) -> Result<u32>; fn inject(&mut self, batch: &mut DBTransaction) -> Result<u32>; fn state(&self, _id: &H256) -> Option<Bytes>; fn backing(&self) -> &Arc<KeyValueDB>; fn consolidate(&mut self, overlay: MemoryDB<KeccakHasher>); fn journal_size(&self) -> usize { ... } fn earliest_era(&self) -> Option<u64> { ... } fn is_pruned(&self) -> bool { ... } fn flush(&self) { ... } }
A HashDB
which can manage a short-term journal potentially containing many forks of mutually
exclusive actions.
Required Methods
fn boxed_clone(&self) -> Box<JournalDB>
Return a copy of ourself, in a box.
fn mem_used(&self) -> usize
Returns heap memory size used
fn is_empty(&self) -> bool
Check if this database has any commits
fn latest_era(&self) -> Option<u64>
Get the latest era in the DB. None if there isn't yet any data in there.
fn journal_under(
&mut self,
batch: &mut DBTransaction,
now: u64,
id: &H256
) -> Result<u32>
&mut self,
batch: &mut DBTransaction,
now: u64,
id: &H256
) -> Result<u32>
Journal recent database operations as being associated with a given era and id.
fn mark_canonical(
&mut self,
batch: &mut DBTransaction,
era: u64,
id: &H256
) -> Result<u32>
&mut self,
batch: &mut DBTransaction,
era: u64,
id: &H256
) -> Result<u32>
Mark a given block as canonical, indicating that competing blocks' states may be pruned out.
fn inject(&mut self, batch: &mut DBTransaction) -> Result<u32>
Commit all queued insert and delete operations without affecting any journalling -- this requires that all insertions and deletions are indeed canonical and will likely lead to an invalid database if that assumption is violated.
Any keys or values inserted or deleted must be completely independent of those affected
by any previous commit
operations. Essentially, this means that inject
can be used
either to restore a state to a fresh database, or to insert data which may only be journalled
from this point onwards.
fn state(&self, _id: &H256) -> Option<Bytes>
State data query
fn backing(&self) -> &Arc<KeyValueDB>
Get backing database.
fn consolidate(&mut self, overlay: MemoryDB<KeccakHasher>)
Consolidate all the insertions and deletions in the given memory overlay.
Provided Methods
fn journal_size(&self) -> usize
Returns the size of journalled state in memory. This function has a considerable speed requirement -- it must be fast enough to call several times per block imported.
fn earliest_era(&self) -> Option<u64>
Get the earliest era in the DB. None if there isn't yet any data in there.
fn is_pruned(&self) -> bool
Whether this database is pruned.
fn flush(&self)
Clear internal strucutres. This should called after changes have been written to the backing strage