chore: Move HistoryWriter trait to storage-api and reexport it from old provider crate (#12480)

This commit is contained in:
Panagiotis Ganelis
2024-11-12 19:35:51 +01:00
committed by GitHub
parent 4a8eb7a0c0
commit fa5daef07d
6 changed files with 8 additions and 3 deletions

View File

@@ -46,6 +46,9 @@ pub use reth_chain_state::{
CanonStateNotifications, CanonStateSubscriptions,
};
// reexport HistoryWriter trait
pub use reth_storage_api::HistoryWriter;
pub(crate) fn to_range<R: std::ops::RangeBounds<u64>>(bounds: R) -> std::ops::Range<u64> {
let start = match bounds.start_bound() {
std::ops::Bound::Included(&v) => v,

View File

@@ -1,57 +0,0 @@
use alloy_primitives::{Address, BlockNumber, B256};
use auto_impl::auto_impl;
use reth_db::models::{AccountBeforeTx, BlockNumberAddress};
use reth_primitives::StorageEntry;
use reth_storage_errors::provider::ProviderResult;
use std::ops::{RangeBounds, 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<'a>(
&self,
changesets: impl Iterator<Item = &'a (BlockNumber, AccountBeforeTx)>,
) -> ProviderResult<usize>;
/// Unwind and clear account history indices in a given block range.
///
/// Returns number of changesets walked.
fn unwind_account_history_indices_range(
&self,
range: impl RangeBounds<BlockNumber>,
) -> ProviderResult<usize>;
/// Insert account change index to database. Used inside AccountHistoryIndex stage
fn insert_account_history_index(
&self,
index_updates: impl IntoIterator<Item = (Address, impl IntoIterator<Item = u64>)>,
) -> ProviderResult<()>;
/// Unwind and clear storage history indices.
///
/// Returns number of changesets walked.
fn unwind_storage_history_indices(
&self,
changesets: impl Iterator<Item = (BlockNumberAddress, StorageEntry)>,
) -> ProviderResult<usize>;
/// Unwind and clear storage history indices in a given block range.
///
/// Returns number of changesets walked.
fn unwind_storage_history_indices_range(
&self,
range: impl RangeBounds<BlockNumberAddress>,
) -> ProviderResult<usize>;
/// Insert storage change index to database. Used inside StorageHistoryIndex stage
fn insert_storage_history_index(
&self,
storage_transitions: impl IntoIterator<Item = ((Address, B256), impl IntoIterator<Item = u64>)>,
) -> ProviderResult<()>;
/// Read account/storage changesets and update account/storage history indices.
fn update_history_indices(&self, range: RangeInclusive<BlockNumber>) -> ProviderResult<()>;
}

View File

@@ -26,9 +26,6 @@ pub use hashing::HashingWriter;
mod trie;
pub use trie::{StorageTrieWriter, TrieWriter};
mod history;
pub use history::HistoryWriter;
mod static_file_provider;
pub use static_file_provider::StaticFileProviderFactory;