reth::providers

Trait HashingWriter

pub trait HashingWriter: Send + Sync {
    // Required methods
    fn unwind_account_hashing<'a>(
        &self,
        changesets: impl Iterator<Item = &'a (u64, AccountBeforeTx)>,
    ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>;
    fn unwind_account_hashing_range(
        &self,
        range: impl RangeBounds<u64>,
    ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>;
    fn insert_account_for_hashing(
        &self,
        accounts: impl IntoIterator<Item = (Address, Option<Account>)>,
    ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>;
    fn unwind_storage_hashing(
        &self,
        changesets: impl Iterator<Item = (BlockNumberAddress, StorageEntry)>,
    ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>;
    fn unwind_storage_hashing_range(
        &self,
        range: impl RangeBounds<BlockNumberAddress>,
    ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>;
    fn insert_storage_for_hashing(
        &self,
        storages: impl IntoIterator<Item = (Address, impl IntoIterator<Item = StorageEntry>)>,
    ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>;
    fn insert_hashes(
        &self,
        range: RangeInclusive<u64>,
        end_block_hash: FixedBytes<32>,
        expected_state_root: FixedBytes<32>,
    ) -> Result<(), ProviderError>;
}
Expand description

Hashing Writer

Required Methods§

fn unwind_account_hashing<'a>( &self, changesets: impl Iterator<Item = &'a (u64, AccountBeforeTx)>, ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>

Unwind and clear account hashing.

§Returns

Set of hashed keys of updated accounts.

fn unwind_account_hashing_range( &self, range: impl RangeBounds<u64>, ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>

Unwind and clear account hashing in a given block range.

§Returns

Set of hashed keys of updated accounts.

fn insert_account_for_hashing( &self, accounts: impl IntoIterator<Item = (Address, Option<Account>)>, ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>

Inserts all accounts into reth_db::tables::AccountsHistory table.

§Returns

Set of hashed keys of updated accounts.

fn unwind_storage_hashing( &self, changesets: impl Iterator<Item = (BlockNumberAddress, StorageEntry)>, ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>

Unwind and clear storage hashing

§Returns

Mapping of hashed keys of updated accounts to their respective updated hashed slots.

fn unwind_storage_hashing_range( &self, range: impl RangeBounds<BlockNumberAddress>, ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>

Unwind and clear storage hashing in a given block range.

§Returns

Mapping of hashed keys of updated accounts to their respective updated hashed slots.

fn insert_storage_for_hashing( &self, storages: impl IntoIterator<Item = (Address, impl IntoIterator<Item = StorageEntry>)>, ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>

Iterates over storages and inserts them to hashing table.

§Returns

Mapping of hashed keys of updated accounts to their respective updated hashed slots.

fn insert_hashes( &self, range: RangeInclusive<u64>, end_block_hash: FixedBytes<32>, expected_state_root: FixedBytes<32>, ) -> Result<(), ProviderError>

Calculate the hashes of all changed accounts and storages, and finally calculate the state root.

The hashes are calculated from fork_block_number + 1 to current_block_number.

The resulting state root is compared with expected_state_root.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl<'b, T> HashingWriter for &'b T
where T: 'b + HashingWriter + ?Sized, &'b T: Send + Sync,

§

fn unwind_account_hashing<'a>( &self, changesets: impl Iterator<Item = &'a (u64, AccountBeforeTx)>, ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>

§

fn unwind_account_hashing_range( &self, range: impl RangeBounds<u64>, ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>

§

fn insert_account_for_hashing( &self, accounts: impl IntoIterator<Item = (Address, Option<Account>)>, ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>

§

fn unwind_storage_hashing( &self, changesets: impl Iterator<Item = (BlockNumberAddress, StorageEntry)>, ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>

§

fn unwind_storage_hashing_range( &self, range: impl RangeBounds<BlockNumberAddress>, ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>

§

fn insert_storage_for_hashing( &self, storages: impl IntoIterator<Item = (Address, impl IntoIterator<Item = StorageEntry>)>, ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>

§

fn insert_hashes( &self, range: RangeInclusive<u64>, end_block_hash: FixedBytes<32>, expected_state_root: FixedBytes<32>, ) -> Result<(), ProviderError>

§

impl<T> HashingWriter for Box<T>
where T: HashingWriter + ?Sized, Box<T>: Send + Sync,

§

fn unwind_account_hashing<'a>( &self, changesets: impl Iterator<Item = &'a (u64, AccountBeforeTx)>, ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>

§

fn unwind_account_hashing_range( &self, range: impl RangeBounds<u64>, ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>

§

fn insert_account_for_hashing( &self, accounts: impl IntoIterator<Item = (Address, Option<Account>)>, ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>

§

fn unwind_storage_hashing( &self, changesets: impl Iterator<Item = (BlockNumberAddress, StorageEntry)>, ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>

§

fn unwind_storage_hashing_range( &self, range: impl RangeBounds<BlockNumberAddress>, ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>

§

fn insert_storage_for_hashing( &self, storages: impl IntoIterator<Item = (Address, impl IntoIterator<Item = StorageEntry>)>, ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>

§

fn insert_hashes( &self, range: RangeInclusive<u64>, end_block_hash: FixedBytes<32>, expected_state_root: FixedBytes<32>, ) -> Result<(), ProviderError>

§

impl<T> HashingWriter for Arc<T>
where T: HashingWriter + ?Sized, Arc<T>: Send + Sync,

§

fn unwind_account_hashing<'a>( &self, changesets: impl Iterator<Item = &'a (u64, AccountBeforeTx)>, ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>

§

fn unwind_account_hashing_range( &self, range: impl RangeBounds<u64>, ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>

§

fn insert_account_for_hashing( &self, accounts: impl IntoIterator<Item = (Address, Option<Account>)>, ) -> Result<BTreeMap<FixedBytes<32>, Option<Account>>, ProviderError>

§

fn unwind_storage_hashing( &self, changesets: impl Iterator<Item = (BlockNumberAddress, StorageEntry)>, ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>

§

fn unwind_storage_hashing_range( &self, range: impl RangeBounds<BlockNumberAddress>, ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>

§

fn insert_storage_for_hashing( &self, storages: impl IntoIterator<Item = (Address, impl IntoIterator<Item = StorageEntry>)>, ) -> Result<HashMap<FixedBytes<32>, BTreeSet<FixedBytes<32>>>, ProviderError>

§

fn insert_hashes( &self, range: RangeInclusive<u64>, end_block_hash: FixedBytes<32>, expected_state_root: FixedBytes<32>, ) -> Result<(), ProviderError>

Implementors§

Source§

impl<TX, N> HashingWriter for DatabaseProvider<TX, N>
where TX: DbTxMut + DbTx + 'static, N: NodeTypes,