use auto_impl::auto_impl; use reth_db_api::models::BlockNumberAddress; use reth_primitives::{Address, BlockNumber, B256}; use reth_storage_errors::provider::ProviderResult; use std::{ collections::BTreeMap, ops::{Range, RangeInclusive}, }; /// History Writer #[auto_impl(&, Arc, Box)] pub trait HistoryWriter: Send + Sync { /// Unwind and clear account history indices. /// /// Returns number of changesets walked. fn unwind_account_history_indices( &self, range: RangeInclusive, ) -> ProviderResult; /// Insert account change index to database. Used inside AccountHistoryIndex stage fn insert_account_history_index( &self, account_transitions: BTreeMap>, ) -> ProviderResult<()>; /// Unwind and clear storage history indices. /// /// Returns number of changesets walked. fn unwind_storage_history_indices( &self, range: Range, ) -> ProviderResult; /// Insert storage change index to database. Used inside StorageHistoryIndex stage fn insert_storage_history_index( &self, storage_transitions: BTreeMap<(Address, B256), Vec>, ) -> ProviderResult<()>; /// Read account/storage changesets and update account/storage history indices. fn update_history_indices(&self, range: RangeInclusive) -> ProviderResult<()>; }