mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: introduce ProviderFactoryBuilder (#13989)
This commit is contained in:
@ -15,7 +15,9 @@ use reth_chainspec::{ChainInfo, EthereumHardforks};
|
||||
use reth_db::{init_db, mdbx::DatabaseArguments, DatabaseEnv};
|
||||
use reth_db_api::{database::Database, models::StoredBlockBodyIndices};
|
||||
use reth_errors::{RethError, RethResult};
|
||||
use reth_node_types::{BlockTy, HeaderTy, NodeTypesWithDB, ReceiptTy, TxTy};
|
||||
use reth_node_types::{
|
||||
BlockTy, HeaderTy, NodeTypes, NodeTypesWithDB, NodeTypesWithDBAdapter, ReceiptTy, TxTy,
|
||||
};
|
||||
use reth_primitives::{RecoveredBlock, SealedBlock, SealedHeader, StaticFileSegment};
|
||||
use reth_prune_types::{PruneCheckpoint, PruneModes, PruneSegment};
|
||||
use reth_stages_types::{StageCheckpoint, StageId};
|
||||
@ -40,6 +42,9 @@ pub use provider::{DatabaseProvider, DatabaseProviderRO, DatabaseProviderRW};
|
||||
|
||||
use super::ProviderNodeTypes;
|
||||
|
||||
mod builder;
|
||||
pub use builder::{ProviderFactoryBuilder, ReadOnlyConfig};
|
||||
|
||||
mod metrics;
|
||||
|
||||
mod chain;
|
||||
@ -49,7 +54,7 @@ pub use chain::*;
|
||||
///
|
||||
/// This provider implements most provider or provider factory traits.
|
||||
pub struct ProviderFactory<N: NodeTypesWithDB> {
|
||||
/// Database
|
||||
/// Database instance
|
||||
db: N::DB,
|
||||
/// Chain spec
|
||||
chain_spec: Arc<N::ChainSpec>,
|
||||
@ -61,19 +66,10 @@ pub struct ProviderFactory<N: NodeTypesWithDB> {
|
||||
storage: Arc<N::Storage>,
|
||||
}
|
||||
|
||||
impl<N> fmt::Debug for ProviderFactory<N>
|
||||
where
|
||||
N: NodeTypesWithDB<DB: fmt::Debug, ChainSpec: fmt::Debug, Storage: fmt::Debug>,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let Self { db, chain_spec, static_file_provider, prune_modes, storage } = self;
|
||||
f.debug_struct("ProviderFactory")
|
||||
.field("db", &db)
|
||||
.field("chain_spec", &chain_spec)
|
||||
.field("static_file_provider", &static_file_provider)
|
||||
.field("prune_modes", &prune_modes)
|
||||
.field("storage", &storage)
|
||||
.finish()
|
||||
impl<N: NodeTypes> ProviderFactory<NodeTypesWithDBAdapter<N, Arc<DatabaseEnv>>> {
|
||||
/// Instantiates the builder for this type
|
||||
pub fn builder() -> ProviderFactoryBuilder<N> {
|
||||
ProviderFactoryBuilder::default()
|
||||
}
|
||||
}
|
||||
|
||||
@ -630,6 +626,22 @@ impl<N: ProviderNodeTypes> HashedPostStateProvider for ProviderFactory<N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<N> fmt::Debug for ProviderFactory<N>
|
||||
where
|
||||
N: NodeTypesWithDB<DB: fmt::Debug, ChainSpec: fmt::Debug, Storage: fmt::Debug>,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let Self { db, chain_spec, static_file_provider, prune_modes, storage } = self;
|
||||
f.debug_struct("ProviderFactory")
|
||||
.field("db", &db)
|
||||
.field("chain_spec", &chain_spec)
|
||||
.field("static_file_provider", &static_file_provider)
|
||||
.field("prune_modes", &prune_modes)
|
||||
.field("storage", &storage)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: NodeTypesWithDB> Clone for ProviderFactory<N> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
|
||||
Reference in New Issue
Block a user