Skip to main content

StateProvider

Trait StateProvider 

Source
pub trait StateProvider:
    BlockHashReader
    + AccountReader
    + BytecodeReader
    + StateRootProvider
    + StorageRootProvider
    + StateProofProvider
    + HashedPostStateProvider {
    // Required methods
    fn storage(
        &self,
        account: Address,
        storage_key: StorageKey,
    ) -> ProviderResult<Option<StorageValue>>;
    fn storage_by_hashed_key(
        &self,
        address: Address,
        hashed_storage_key: StorageKey,
    ) -> ProviderResult<Option<StorageValue>>;

    // Provided methods
    fn account_code(&self, addr: &Address) -> ProviderResult<Option<Bytecode>> { ... }
    fn account_balance(&self, addr: &Address) -> ProviderResult<Option<U256>> { ... }
    fn account_nonce(&self, addr: &Address) -> ProviderResult<Option<u64>> { ... }
}
Expand description

An abstraction for a type that provides state data.

Required Methods§

Source

fn storage( &self, account: Address, storage_key: StorageKey, ) -> ProviderResult<Option<StorageValue>>

Get storage of given account.

When use_hashed_state is enabled, the account and storage_key are hashed internally before lookup. Callers must pass unhashed (plain) values.

Source

fn storage_by_hashed_key( &self, address: Address, hashed_storage_key: StorageKey, ) -> ProviderResult<Option<StorageValue>>

Get storage using a pre-hashed storage key.

Unlike Self::storage, hashed_storage_key must already be keccak256-hashed. The address remains unhashed (plain) since history indices are keyed by plain address. This is used when changeset keys are pre-hashed (e.g., use_hashed_state mode) to avoid double-hashing.

Provided Methods§

Source

fn account_code(&self, addr: &Address) -> ProviderResult<Option<Bytecode>>

Get account code by its address.

Returns None if the account doesn’t exist or account is not a contract

Source

fn account_balance(&self, addr: &Address) -> ProviderResult<Option<U256>>

Get account balance by its address.

Returns None if the account doesn’t exist

Source

fn account_nonce(&self, addr: &Address) -> ProviderResult<Option<u64>>

Get account nonce by its address.

Returns None if the account doesn’t exist

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + StateProvider + ?Sized> StateProvider for &'a T

Source§

fn storage( &self, account: Address, storage_key: StorageKey, ) -> ProviderResult<Option<StorageValue>>

Source§

fn storage_by_hashed_key( &self, address: Address, hashed_storage_key: StorageKey, ) -> ProviderResult<Option<StorageValue>>

Source§

fn account_code(&self, addr: &Address) -> ProviderResult<Option<Bytecode>>

Source§

fn account_balance(&self, addr: &Address) -> ProviderResult<Option<U256>>

Source§

fn account_nonce(&self, addr: &Address) -> ProviderResult<Option<u64>>

Source§

impl<T: StateProvider + ?Sized> StateProvider for Box<T>

Source§

fn storage( &self, account: Address, storage_key: StorageKey, ) -> ProviderResult<Option<StorageValue>>

Source§

fn storage_by_hashed_key( &self, address: Address, hashed_storage_key: StorageKey, ) -> ProviderResult<Option<StorageValue>>

Source§

fn account_code(&self, addr: &Address) -> ProviderResult<Option<Bytecode>>

Source§

fn account_balance(&self, addr: &Address) -> ProviderResult<Option<U256>>

Source§

fn account_nonce(&self, addr: &Address) -> ProviderResult<Option<u64>>

Implementors§

Source§

impl<C: Send + Sync, N: NodePrimitives> StateProvider for NoopProvider<C, N>