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