Struct state_db::StateDB[][src]

pub struct StateDB { /* fields omitted */ }

State database abstraction. Manages shared global state cache which reflects the canonical state as it is on the disk. All the entries in the cache are clean. A clone of StateDB may be created as canonical or not. For canonical clones local cache is accumulated and applied in sync_cache For non-canonical clones local cache is dropped.

Global cache propagation. After a State object has been committed to the trie it propagates its local cache into the StateDB local cache using add_to_account_cache function. Then, after the block has been added to the chain the local cache in the StateDB is propagated into the global cache.

Implementations

impl StateDB[src]

pub fn new(db: Box<dyn JournalDB>, cache_size: usize) -> StateDB[src]

Create a new instance wrapping JournalDB and the maximum allowed size of the LRU cache in bytes. Actual used memory may (read: will) be higher due to bookkeeping.

pub fn load_bloom(db: &dyn KeyValueDB) -> Bloom[src]

Loads accounts bloom from the database This bloom is used to handle request for the non-existent account fast

pub fn commit_bloom(
    batch: &mut DBTransaction,
    journal: BloomJournal
) -> Result<()>
[src]

Commit blooms journal to the database transaction

pub fn journal_under(
    &mut self,
    batch: &mut DBTransaction,
    now: u64,
    id: &H256
) -> Result<u32>
[src]

Journal all recent operations under the given era and ID.

pub fn mark_canonical(
    &mut self,
    batch: &mut DBTransaction,
    end_era: u64,
    canon_id: &H256
) -> Result<u32>
[src]

Mark a given candidate from an ancient era as canonical, enacting its removals from the backing database and reverting any non-canonical historical commit’s insertions.

pub fn sync_cache(
    &mut self,
    enacted: &[H256],
    retracted: &[H256],
    is_best: bool
)
[src]

Propagate local cache into the global cache and synchonize the global cache with the best block state. This function updates the global cache by removing entries that are invalidated by chain reorganization. sync_cache should be called after the block has been committed and the blockchain route has ben calculated.

pub fn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue>[src]

Conversion method to interpret self as HashDB reference

pub fn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue>[src]

Conversion method to interpret self as mutable HashDB reference

pub fn boxed_clone(&self) -> StateDB[src]

Clone the database.

pub fn boxed_clone_canon(&self, parent: &H256) -> StateDB[src]

Clone the database for a canonical state.

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

Check if pruning is enabled on the database.

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

Heap size used.

pub fn journal_db(&self) -> &dyn JournalDB[src]

Returns underlying JournalDB.

pub fn cache_size(&self) -> usize[src]

Query how much memory is set aside for the accounts cache (in bytes).

Trait Implementations

impl Backend for StateDB[src]

impl Clone for StateDB[src]

Auto Trait Implementations

impl !RefUnwindSafe for StateDB

impl Send for StateDB

impl Sync for StateDB

impl Unpin for StateDB

impl !UnwindSafe for StateDB

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,