Trait journaldb::JournalDB[][src]

pub trait JournalDB: HashDB<KeccakHasher, DBValue> {
    fn boxed_clone(&self) -> Box<dyn 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<dyn KeyValueDB>;
fn consolidate(
        &mut self,
        overlay: MemoryDB<KeccakHasher, HashKey<KeccakHasher>, DBValue>
    );
fn keys(&self) -> HashMap<H256, i32>; fn journal_size(&self) -> usize { ... }
fn earliest_era(&self) -> Option<u64> { ... }
fn is_prunable(&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<dyn JournalDB>[src]

Return a copy of ourself, in a box.

fn mem_used(&self) -> usize[src]

Returns heap memory size used

fn is_empty(&self) -> bool[src]

Check if this database has any commits

fn latest_era(&self) -> Option<u64>[src]

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>
[src]

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>
[src]

Mark a given block as canonical, indicating that competing blocks’ states may be pruned out.

fn inject(&mut self, batch: &mut DBTransaction) -> Result<u32>[src]

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>[src]

State data query

fn backing(&self) -> &Arc<dyn KeyValueDB>[src]

Get backing database.

fn consolidate(
    &mut self,
    overlay: MemoryDB<KeccakHasher, HashKey<KeccakHasher>, DBValue>
)
[src]

Consolidate all the insertions and deletions in the given memory overlay.

fn keys(&self) -> HashMap<H256, i32>[src]

Primarily use for tests, highly inefficient.

Loading content...

Provided methods

fn journal_size(&self) -> usize[src]

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>[src]

Get the earliest era in the DB. None if there isn’t yet any data in there.

fn is_prunable(&self) -> bool[src]

Whether this database is pruned.

fn flush(&self)[src]

Clear internal structure. This should be called after changes have been written to the backing storage.

Loading content...

Implementors

Loading content...