reth_storage_api/
storage.rs1use alloy_primitives::{Address, BlockNumber, B256};
2use reth_db_api::models::BlockNumberAddress;
3use reth_primitives::StorageEntry;
4use reth_storage_errors::provider::ProviderResult;
5use std::{
6 collections::{BTreeMap, BTreeSet},
7 ops::RangeInclusive,
8};
9
10#[auto_impl::auto_impl(&, Arc, Box)]
12pub trait StorageReader: Send + Sync {
13 fn plain_state_storages(
15 &self,
16 addresses_with_keys: impl IntoIterator<Item = (Address, impl IntoIterator<Item = B256>)>,
17 ) -> ProviderResult<Vec<(Address, Vec<StorageEntry>)>>;
18
19 fn changed_storages_with_range(
21 &self,
22 range: RangeInclusive<BlockNumber>,
23 ) -> ProviderResult<BTreeMap<Address, BTreeSet<B256>>>;
24
25 fn changed_storages_and_blocks_with_range(
30 &self,
31 range: RangeInclusive<BlockNumber>,
32 ) -> ProviderResult<BTreeMap<(Address, B256), Vec<u64>>>;
33}
34
35#[auto_impl::auto_impl(&, Arc, Box)]
37pub trait StorageChangeSetReader: Send + Sync {
38 fn storage_changeset(
40 &self,
41 block_number: BlockNumber,
42 ) -> ProviderResult<Vec<(BlockNumberAddress, StorageEntry)>>;
43}
44
45#[derive(Debug, Copy, Clone, PartialEq, Eq)]
47pub enum StorageLocation {
48 StaticFiles,
50 Database,
52 Both,
54}
55
56impl StorageLocation {
57 pub const fn static_files(&self) -> bool {
59 matches!(self, Self::StaticFiles | Self::Both)
60 }
61
62 pub const fn database(&self) -> bool {
64 matches!(self, Self::Database | Self::Both)
65 }
66}