reth_storage_api/
history.rs1use alloy_primitives::{Address, BlockNumber, B256};
2use auto_impl::auto_impl;
3use core::ops::{RangeBounds, RangeInclusive};
4use reth_db_api::models::BlockNumberAddress;
5use reth_db_models::AccountBeforeTx;
6use reth_primitives_traits::StorageEntry;
7use reth_storage_errors::provider::ProviderResult;
8
9#[auto_impl(&, Arc, Box)]
11pub trait HistoryWriter: Send + Sync {
12    fn unwind_account_history_indices<'a>(
16        &self,
17        changesets: impl Iterator<Item = &'a (BlockNumber, AccountBeforeTx)>,
18    ) -> ProviderResult<usize>;
19
20    fn unwind_account_history_indices_range(
24        &self,
25        range: impl RangeBounds<BlockNumber>,
26    ) -> ProviderResult<usize>;
27
28    fn insert_account_history_index(
30        &self,
31        index_updates: impl IntoIterator<Item = (Address, impl IntoIterator<Item = u64>)>,
32    ) -> ProviderResult<()>;
33
34    fn unwind_storage_history_indices(
38        &self,
39        changesets: impl Iterator<Item = (BlockNumberAddress, StorageEntry)>,
40    ) -> ProviderResult<usize>;
41
42    fn unwind_storage_history_indices_range(
46        &self,
47        range: impl RangeBounds<BlockNumberAddress>,
48    ) -> ProviderResult<usize>;
49
50    fn insert_storage_history_index(
52        &self,
53        storage_transitions: impl IntoIterator<Item = ((Address, B256), impl IntoIterator<Item = u64>)>,
54    ) -> ProviderResult<()>;
55
56    fn update_history_indices(&self, range: RangeInclusive<BlockNumber>) -> ProviderResult<()>;
58}