reth_storage_api/
hashing.rs1use alloy_primitives::{map::HashMap, Address, BlockNumber, B256};
2use auto_impl::auto_impl;
3use reth_db::models::{AccountBeforeTx, BlockNumberAddress};
4use reth_primitives::{Account, StorageEntry};
5use reth_storage_errors::provider::ProviderResult;
6use std::{
7 collections::{BTreeMap, BTreeSet},
8 ops::{RangeBounds, RangeInclusive},
9};
10
11#[auto_impl(&, Arc, Box)]
13pub trait HashingWriter: Send + Sync {
14 fn unwind_account_hashing<'a>(
20 &self,
21 changesets: impl Iterator<Item = &'a (BlockNumber, AccountBeforeTx)>,
22 ) -> ProviderResult<BTreeMap<B256, Option<Account>>>;
23
24 fn unwind_account_hashing_range(
30 &self,
31 range: impl RangeBounds<BlockNumber>,
32 ) -> ProviderResult<BTreeMap<B256, Option<Account>>>;
33
34 fn insert_account_for_hashing(
40 &self,
41 accounts: impl IntoIterator<Item = (Address, Option<Account>)>,
42 ) -> ProviderResult<BTreeMap<B256, Option<Account>>>;
43
44 fn unwind_storage_hashing(
50 &self,
51 changesets: impl Iterator<Item = (BlockNumberAddress, StorageEntry)>,
52 ) -> ProviderResult<HashMap<B256, BTreeSet<B256>>>;
53
54 fn unwind_storage_hashing_range(
60 &self,
61 range: impl RangeBounds<BlockNumberAddress>,
62 ) -> ProviderResult<HashMap<B256, BTreeSet<B256>>>;
63
64 fn insert_storage_for_hashing(
70 &self,
71 storages: impl IntoIterator<Item = (Address, impl IntoIterator<Item = StorageEntry>)>,
72 ) -> ProviderResult<HashMap<B256, BTreeSet<B256>>>;
73
74 fn insert_hashes(
81 &self,
82 range: RangeInclusive<BlockNumber>,
83 end_block_hash: B256,
84 expected_state_root: B256,
85 ) -> ProviderResult<()>;
86}