reth_storage_api/
hashing.rs
1use alloc::collections::{BTreeMap, BTreeSet};
2use alloy_primitives::{map::HashMap, Address, BlockNumber, B256};
3use auto_impl::auto_impl;
4use core::ops::{RangeBounds, RangeInclusive};
5use reth_db_api::models::BlockNumberAddress;
6use reth_db_models::AccountBeforeTx;
7use reth_primitives_traits::{Account, StorageEntry};
8use reth_storage_errors::provider::ProviderResult;
9
10#[auto_impl(&, Arc, Box)]
12pub trait HashingWriter: Send + Sync {
13 fn unwind_account_hashing<'a>(
19 &self,
20 changesets: impl Iterator<Item = &'a (BlockNumber, AccountBeforeTx)>,
21 ) -> ProviderResult<BTreeMap<B256, Option<Account>>>;
22
23 fn unwind_account_hashing_range(
29 &self,
30 range: impl RangeBounds<BlockNumber>,
31 ) -> ProviderResult<BTreeMap<B256, Option<Account>>>;
32
33 fn insert_account_for_hashing(
39 &self,
40 accounts: impl IntoIterator<Item = (Address, Option<Account>)>,
41 ) -> ProviderResult<BTreeMap<B256, Option<Account>>>;
42
43 fn unwind_storage_hashing(
49 &self,
50 changesets: impl Iterator<Item = (BlockNumberAddress, StorageEntry)>,
51 ) -> ProviderResult<HashMap<B256, BTreeSet<B256>>>;
52
53 fn unwind_storage_hashing_range(
59 &self,
60 range: impl RangeBounds<BlockNumberAddress>,
61 ) -> ProviderResult<HashMap<B256, BTreeSet<B256>>>;
62
63 fn insert_storage_for_hashing(
69 &self,
70 storages: impl IntoIterator<Item = (Address, impl IntoIterator<Item = StorageEntry>)>,
71 ) -> ProviderResult<HashMap<B256, BTreeSet<B256>>>;
72
73 fn insert_hashes(
80 &self,
81 range: RangeInclusive<BlockNumber>,
82 end_block_hash: B256,
83 expected_state_root: B256,
84 ) -> ProviderResult<()>;
85}