pub struct StateDB { /* private fields */ }
Expand description

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

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.

Journal all recent operations under the given era and ID.

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.

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.

Conversion method to interpret self as HashDB reference

Conversion method to interpret self as mutable HashDB reference

Clone the database.

Clone the database for a canonical state.

Check if pruning is enabled on the database.

Heap size used.

Returns underlying JournalDB.

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

Trait Implementations

Treat the backend as a read-only hashdb.

Treat the backend as a writeable hashdb.

t_nb 9.4 Add an account entry to the cache.

Add a global code cache entry. This doesn’t need to worry about canonicality because it simply maps hashes to raw code and will always be correct in the absence of hash collisions. Read more

Get basic copy of the cached account. Not required to include storage. Returns ‘None’ if cache is disabled or if the account is not cached. Read more

Get value from a cached account. None is passed to the closure if the account entry cached is known not to exist. None is returned if the entry is not cached. Read more

Get cached code based on hash.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.