pub trait JournalDB: KeyedHashDB {
Show 14 methods
fn boxed_clone(&self) -> Box<dyn JournalDB>;
fn get_sizes(&self, sizes: &mut BTreeMap<String, 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 backing(&self) -> &Arc<dyn KeyValueDB>;
fn consolidate(&mut self, overlay: MemoryDB<KeccakHasher, DBValue>);
fn state(&self, id: &H256) -> Option<Bytes>;
fn journal_size(&self) -> usize { ... }
fn earliest_era(&self) -> Option<u64> { ... }
fn is_pruned(&self) -> bool { ... }
fn flush(&self) { ... }
}
Expand description
A HashDB
which can manage a short-term journal potentially containing many forks of mutually
exclusive actions.
Required methods
fn boxed_clone(&self) -> Box<dyn JournalDB>
fn boxed_clone(&self) -> Box<dyn JournalDB>
Return a copy of ourself, in a box.
fn latest_era(&self) -> Option<u64>
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>
fn journal_under(
&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>
fn mark_canonical(
&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>
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 backing(&self) -> &Arc<dyn KeyValueDB>
fn backing(&self) -> &Arc<dyn KeyValueDB>
Get backing database.
fn consolidate(&mut self, overlay: MemoryDB<KeccakHasher, DBValue>)
fn consolidate(&mut self, overlay: MemoryDB<KeccakHasher, DBValue>)
Consolidate all the insertions and deletions in the given memory overlay.
Provided methods
fn journal_size(&self) -> usize
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>
fn earliest_era(&self) -> Option<u64>
Get the earliest era in the DB. None if there isn’t yet any data in there.