Struct ethcore::state::State[][src]

pub struct State<B> { /* fields omitted */ }

Representation of the entire state of all accounts in the system.

State can work together with StateDB to share account cache.

Local cache contains changes made locally and changes accumulated locally from previous commits. Global cache reflects the database state and never contains any changes.

Cache items contains account data, or the flag that account does not exist and modification state (see AccountState)

Account data can be in the following cache states:

All read-only state queries check local cache/modifications first, then global state cache. If data is not found in any of the caches it is loaded from the DB to the local cache.

**** IMPORTANT ************************************************************* All the modifications to the account data must set the Dirty state in the AccountEntry. This is done in require and require_or_from. So just use that.


Upon destruction all the local cache data propagated into the global cache. Propagated items might be rejected if current state is non-canonical.

State checkpointing.

A new checkpoint can be created with checkpoint(). checkpoints can be created in a hierarchy. When a checkpoint is active all changes are applied directly into cache and the original value is copied into an active checkpoint. Reverting a checkpoint with revert_to_checkpoint involves copying original values from the latest checkpoint back into cache. The code takes care not to overwrite cached storage while doing that. checkpoint can be discarded with discard_checkpoint. All of the orignal backed-up values are moved into a parent checkpoint (if any).

Methods

impl<B: Backend> State<B>
[src]

Creates new state with empty state root Used for tests.

Creates new state with existing state root

Get a VM factory that can execute on this state.

Create a recoverable checkpoint of this state.

Merge last checkpoint with previous.

Revert to the last checkpoint and discard it.

Destroy the current object and return root and database.

Destroy the current object and return single account data.

Return reference to root

Create a new contract at address contract. If there is already an account at the address it will have its code reset, ready for init_code().

Remove an existing account.

Determine whether an account exists.

Determine whether an account exists and if not empty.

Determine whether an account exists and has code or non-zero nonce.

Get the balance of account a.

Get the nonce of account a.

Get the storage root of account a.

Mutate storage of account address so that it is value for key.

Get accounts' code.

Get an account's code hash.

Get accounts' code size.

Add incr to the balance of account a.

Subtract decr from the balance of account a.

Subtracts by from the balance of from and adds it to that of to.

Increment the nonce of account a by 1.

Mutate storage of account a so that it is value for key.

Initialise the code of account a so that it is code. NOTE: Account should have been created with new_contract.

Reset the code of account a so that it is code.

Execute a given transaction, producing a receipt and an optional trace. This will change the state accordingly.

Execute a given transaction with given tracer and VM tracer producing a receipt and an optional trace. This will change the state accordingly.

Commits our cached account changes into the trie.

Clear state cache

Remove any touched empty or dust accounts.

Populate the state from accounts. Used for tests.

Populate a PodAccount map from this state.

Populate a PodAccount map from this state, with another state as the account and storage query.

Returns a StateDiff describing the difference from orig to self. Consumes self.

Replace account code and storage. Creates account if it does not exist.

impl<B: Backend> State<B>
[src]

Prove an account's existence or nonexistence in the state trie. Returns a merkle proof of the account's trie node omitted or an encountered trie error. If the account doesn't exist in the trie, prove that and return defaults. Requires a secure trie to be used for accurate results. account_key == keccak(address)

Prove an account's storage key's existence or nonexistence in the state. Returns a merkle proof of the account's storage trie. Requires a secure trie to be used for correctness. account_key == keccak(address) storage_key == keccak(key)

Trait Implementations

impl<B: Backend> StateInfo for State<B>
[src]

Get the nonce of account a.

Get the balance of account a.

Mutate storage of account address so that it is value for key.

Get accounts' code.

impl<B: Backend> Debug for State<B>
[src]

Formats the value using the given formatter. Read more

impl Clone for State<StateDB>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<B> Send for State<B> where
    B: Send

impl<B> !Sync for State<B>