# Trait ethcore_util::journaldb::traits::JournalDB [−] [src]

    pub trait JournalDB: HashDB {
        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, UtilError>;
        fn mark_canonical(&mut self,
                      batch: &mut DBTransaction,
                      era: u64,
                      id: &H256)
                      -> Result<u32, UtilError>;
        fn inject(&mut self, batch: &mut DBTransaction) -> Result<u32, UtilError>;
        fn state(&self, _id: &H256) -> Option<Bytes>;
        fn backing(&self) -> &Arc<Database>;
        fn consolidate(&mut self, overlay: MemoryDB);

        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, UtilError>`

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, UtilError>`

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

### `fn inject(&mut self, batch: &mut DBTransaction) -> Result<u32, UtilError>`

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<Database>`

Get backing database.

### `fn consolidate(&mut self, overlay: MemoryDB)`

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

## Implementors

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)