Trait reth_storage_api::StateRootProvider

source ·
pub trait StateRootProvider: Send + Sync {
    // Required methods
    fn state_root(&self, hashed_state: HashedPostState) -> ProviderResult<B256>;
    fn state_root_from_nodes(&self, input: TrieInput) -> ProviderResult<B256>;
    fn state_root_with_updates(
        &self,
        hashed_state: HashedPostState,
    ) -> ProviderResult<(B256, TrieUpdates)>;
    fn state_root_from_nodes_with_updates(
        &self,
        input: TrieInput,
    ) -> ProviderResult<(B256, TrieUpdates)>;
}
Expand description

A type that can compute the state root of a given post state.

Required Methods§

source

fn state_root(&self, hashed_state: HashedPostState) -> ProviderResult<B256>

Returns the state root of the BundleState on top of the current state.

§Note

It is recommended to provide a different implementation from state_root_with_updates since it affects the memory usage during state root computation.

source

fn state_root_from_nodes(&self, input: TrieInput) -> ProviderResult<B256>

Returns the state root of the HashedPostState on top of the current state but re-uses the intermediate nodes to speed up the computation. It’s up to the caller to construct the prefix sets and inform the provider of the trie paths that have changes.

source

fn state_root_with_updates( &self, hashed_state: HashedPostState, ) -> ProviderResult<(B256, TrieUpdates)>

Returns the state root of the HashedPostState on top of the current state with trie updates to be committed to the database.

source

fn state_root_from_nodes_with_updates( &self, input: TrieInput, ) -> ProviderResult<(B256, TrieUpdates)>

Returns state root and trie updates. See StateRootProvider::state_root_from_nodes for more info.

Implementations on Foreign Types§

source§

impl<'a, T: 'a + StateRootProvider + ?Sized> StateRootProvider for &'a T
where &'a T: Send + Sync,

source§

fn state_root(&self, hashed_state: HashedPostState) -> ProviderResult<B256>

source§

fn state_root_from_nodes(&self, input: TrieInput) -> ProviderResult<B256>

source§

fn state_root_with_updates( &self, hashed_state: HashedPostState, ) -> ProviderResult<(B256, TrieUpdates)>

source§

fn state_root_from_nodes_with_updates( &self, input: TrieInput, ) -> ProviderResult<(B256, TrieUpdates)>

source§

impl<T: StateRootProvider + ?Sized> StateRootProvider for Box<T>
where Box<T>: Send + Sync,

source§

fn state_root(&self, hashed_state: HashedPostState) -> ProviderResult<B256>

source§

fn state_root_from_nodes(&self, input: TrieInput) -> ProviderResult<B256>

source§

fn state_root_with_updates( &self, hashed_state: HashedPostState, ) -> ProviderResult<(B256, TrieUpdates)>

source§

fn state_root_from_nodes_with_updates( &self, input: TrieInput, ) -> ProviderResult<(B256, TrieUpdates)>

source§

impl<T: StateRootProvider + ?Sized> StateRootProvider for Arc<T>
where Arc<T>: Send + Sync,

source§

fn state_root(&self, hashed_state: HashedPostState) -> ProviderResult<B256>

source§

fn state_root_from_nodes(&self, input: TrieInput) -> ProviderResult<B256>

source§

fn state_root_with_updates( &self, hashed_state: HashedPostState, ) -> ProviderResult<(B256, TrieUpdates)>

source§

fn state_root_from_nodes_with_updates( &self, input: TrieInput, ) -> ProviderResult<(B256, TrieUpdates)>

Implementors§