mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: move triewriter trait (#12598)
This commit is contained in:
@ -17,9 +17,6 @@ pub use state::{StateChangeWriter, StateWriter};
|
||||
|
||||
pub use reth_chainspec::ChainSpecProvider;
|
||||
|
||||
mod trie;
|
||||
pub use trie::{StorageTrieWriter, TrieWriter};
|
||||
|
||||
mod static_file_provider;
|
||||
pub use static_file_provider::StaticFileProviderFactory;
|
||||
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use alloy_primitives::B256;
|
||||
use auto_impl::auto_impl;
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use reth_trie::updates::{StorageTrieUpdates, TrieUpdates};
|
||||
|
||||
/// Trie Writer
|
||||
#[auto_impl(&, Arc, Box)]
|
||||
pub trait TrieWriter: Send + Sync {
|
||||
/// Writes trie updates to the database.
|
||||
///
|
||||
/// Returns the number of entries modified.
|
||||
fn write_trie_updates(&self, trie_updates: &TrieUpdates) -> ProviderResult<usize>;
|
||||
}
|
||||
|
||||
/// Storage Trie Writer
|
||||
#[auto_impl(&, Arc, Box)]
|
||||
pub trait StorageTrieWriter: Send + Sync {
|
||||
/// Writes storage trie updates from the given storage trie map.
|
||||
///
|
||||
/// First sorts the storage trie updates by the hashed address key, writing in sorted order.
|
||||
///
|
||||
/// Returns the number of entries modified.
|
||||
fn write_storage_trie_updates(
|
||||
&self,
|
||||
storage_tries: &HashMap<B256, StorageTrieUpdates>,
|
||||
) -> ProviderResult<usize>;
|
||||
|
||||
/// Writes storage trie updates for the given hashed address.
|
||||
fn write_individual_storage_trie_updates(
|
||||
&self,
|
||||
hashed_address: B256,
|
||||
updates: &StorageTrieUpdates,
|
||||
) -> ProviderResult<usize>;
|
||||
}
|
||||
@ -4,8 +4,8 @@ use alloy_primitives::{
|
||||
};
|
||||
use reth_storage_errors::provider::ProviderResult;
|
||||
use reth_trie::{
|
||||
updates::TrieUpdates, AccountProof, HashedPostState, HashedStorage, MultiProof, StorageProof,
|
||||
TrieInput,
|
||||
updates::{StorageTrieUpdates, TrieUpdates},
|
||||
AccountProof, HashedPostState, HashedStorage, MultiProof, StorageProof, TrieInput,
|
||||
};
|
||||
|
||||
/// A type that can compute the state root of a given post state.
|
||||
@ -85,3 +85,33 @@ pub trait StateProofProvider: Send + Sync {
|
||||
target: HashedPostState,
|
||||
) -> ProviderResult<HashMap<B256, Bytes>>;
|
||||
}
|
||||
|
||||
/// Trie Writer
|
||||
#[auto_impl::auto_impl(&, Arc, Box)]
|
||||
pub trait TrieWriter: Send + Sync {
|
||||
/// Writes trie updates to the database.
|
||||
///
|
||||
/// Returns the number of entries modified.
|
||||
fn write_trie_updates(&self, trie_updates: &TrieUpdates) -> ProviderResult<usize>;
|
||||
}
|
||||
|
||||
/// Storage Trie Writer
|
||||
#[auto_impl::auto_impl(&, Arc, Box)]
|
||||
pub trait StorageTrieWriter: Send + Sync {
|
||||
/// Writes storage trie updates from the given storage trie map.
|
||||
///
|
||||
/// First sorts the storage trie updates by the hashed address key, writing in sorted order.
|
||||
///
|
||||
/// Returns the number of entries modified.
|
||||
fn write_storage_trie_updates(
|
||||
&self,
|
||||
storage_tries: &std::collections::HashMap<B256, StorageTrieUpdates>,
|
||||
) -> ProviderResult<usize>;
|
||||
|
||||
/// Writes storage trie updates for the given hashed address.
|
||||
fn write_individual_storage_trie_updates(
|
||||
&self,
|
||||
hashed_address: B256,
|
||||
updates: &StorageTrieUpdates,
|
||||
) -> ProviderResult<usize>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user