pub trait LoadState {
// Required methods
fn provider(&self) -> impl StateProviderFactory;
fn cache(&self) -> &EthStateCache;
fn pool(&self) -> impl TransactionPool;
// Provided methods
fn state_at_hash(
&self,
block_hash: FixedBytes<32>,
) -> Result<Box<dyn StateProvider>, EthApiError> { ... }
fn state_at_block_id(
&self,
at: BlockId,
) -> Result<Box<dyn StateProvider>, EthApiError> { ... }
fn latest_state(&self) -> Result<Box<dyn StateProvider>, EthApiError> { ... }
fn state_at_block_id_or_latest(
&self,
block_id: Option<BlockId>,
) -> Result<Box<dyn StateProvider>, EthApiError> { ... }
fn evm_env_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(CfgEnvWithHandlerCfg, BlockEnv, BlockId), EthApiError>> + Send
where Self: LoadPendingBlock + SpawnBlocking { ... }
fn evm_env_for_raw_block(
&self,
header: &Header,
) -> impl Future<Output = Result<(CfgEnvWithHandlerCfg, BlockEnv), EthApiError>> + Send
where Self: LoadPendingBlock + SpawnBlocking { ... }
fn transaction_count(
&self,
address: Address,
block_id: Option<BlockId>,
) -> impl Future<Output = Result<Uint<256, 4>, EthApiError>> + Send
where Self: SpawnBlocking { ... }
}
Expand description
Loads state from database.
Behaviour shared by several eth_
RPC methods, not exclusive to eth_
state RPC methods.
Required Methods§
sourcefn provider(&self) -> impl StateProviderFactory
fn provider(&self) -> impl StateProviderFactory
Returns a handle for reading state from database.
Data access in default trait method implementations.
sourcefn cache(&self) -> &EthStateCache
fn cache(&self) -> &EthStateCache
Returns a handle for reading data from memory.
Data access in default (L1) trait method implementations.
sourcefn pool(&self) -> impl TransactionPool
fn pool(&self) -> impl TransactionPool
Returns a handle for reading data from transaction pool.
Data access in default trait method implementations.
Provided Methods§
sourcefn state_at_hash(
&self,
block_hash: FixedBytes<32>,
) -> Result<Box<dyn StateProvider>, EthApiError>
fn state_at_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Box<dyn StateProvider>, EthApiError>
Returns the state at the given block number
sourcefn state_at_block_id(
&self,
at: BlockId,
) -> Result<Box<dyn StateProvider>, EthApiError>
fn state_at_block_id( &self, at: BlockId, ) -> Result<Box<dyn StateProvider>, EthApiError>
Returns the state at the given BlockId
enum.
Note: if not BlockNumberOrTag::Pending
then this
will only return canonical state. See also https://github.com/paradigmxyz/reth/issues/4515
sourcefn latest_state(&self) -> Result<Box<dyn StateProvider>, EthApiError>
fn latest_state(&self) -> Result<Box<dyn StateProvider>, EthApiError>
Returns the latest state
sourcefn state_at_block_id_or_latest(
&self,
block_id: Option<BlockId>,
) -> Result<Box<dyn StateProvider>, EthApiError>
fn state_at_block_id_or_latest( &self, block_id: Option<BlockId>, ) -> Result<Box<dyn StateProvider>, EthApiError>
Returns the state at the given BlockId
enum or the latest.
Convenience function to interprets None
as BlockId::Number(BlockNumberOrTag::Latest)
sourcefn evm_env_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(CfgEnvWithHandlerCfg, BlockEnv, BlockId), EthApiError>> + Sendwhere
Self: LoadPendingBlock + SpawnBlocking,
fn evm_env_at(
&self,
at: BlockId,
) -> impl Future<Output = Result<(CfgEnvWithHandlerCfg, BlockEnv, BlockId), EthApiError>> + Sendwhere
Self: LoadPendingBlock + SpawnBlocking,
sourcefn evm_env_for_raw_block(
&self,
header: &Header,
) -> impl Future<Output = Result<(CfgEnvWithHandlerCfg, BlockEnv), EthApiError>> + Sendwhere
Self: LoadPendingBlock + SpawnBlocking,
fn evm_env_for_raw_block(
&self,
header: &Header,
) -> impl Future<Output = Result<(CfgEnvWithHandlerCfg, BlockEnv), EthApiError>> + Sendwhere
Self: LoadPendingBlock + SpawnBlocking,
Returns the revm evm env for the raw block header
This is used for tracing raw blocks
sourcefn transaction_count(
&self,
address: Address,
block_id: Option<BlockId>,
) -> impl Future<Output = Result<Uint<256, 4>, EthApiError>> + Sendwhere
Self: SpawnBlocking,
fn transaction_count(
&self,
address: Address,
block_id: Option<BlockId>,
) -> impl Future<Output = Result<Uint<256, 4>, EthApiError>> + Sendwhere
Self: SpawnBlocking,
Returns the number of transactions sent from an address at the given block identifier.
If this is BlockNumberOrTag::Pending
then this will
look up the highest transaction in pool and return the next nonce (highest + 1).