reth_storage_api/
storage.rsuse alloy_primitives::{Address, BlockNumber, B256};
use reth_db_api::models::BlockNumberAddress;
use reth_primitives_traits::StorageEntry;
use reth_storage_errors::provider::ProviderResult;
use std::{
collections::{BTreeMap, BTreeSet},
ops::RangeInclusive,
};
#[auto_impl::auto_impl(&, Arc, Box)]
pub trait StorageReader: Send + Sync {
fn plain_state_storages(
&self,
addresses_with_keys: impl IntoIterator<Item = (Address, impl IntoIterator<Item = B256>)>,
) -> ProviderResult<Vec<(Address, Vec<StorageEntry>)>>;
fn changed_storages_with_range(
&self,
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<BTreeMap<Address, BTreeSet<B256>>>;
fn changed_storages_and_blocks_with_range(
&self,
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<BTreeMap<(Address, B256), Vec<u64>>>;
}
#[auto_impl::auto_impl(&, Arc, Box)]
pub trait StorageChangeSetReader: Send + Sync {
fn storage_changeset(
&self,
block_number: BlockNumber,
) -> ProviderResult<Vec<(BlockNumberAddress, StorageEntry)>>;
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum StorageLocation {
StaticFiles,
Database,
Both,
}
impl StorageLocation {
pub const fn static_files(&self) -> bool {
matches!(self, Self::StaticFiles | Self::Both)
}
pub const fn database(&self) -> bool {
matches!(self, Self::Database | Self::Both)
}
}