mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: integrate NodeTypesWithDB (#10698)
Co-authored-by: joshieDo <93316087+joshieDo@users.noreply.github.com>
This commit is contained in:
@ -12,6 +12,8 @@ reth-db.workspace = true
|
||||
reth-primitives.workspace = true
|
||||
reth-provider.workspace = true
|
||||
reth-rpc-types.workspace = true
|
||||
reth-node-ethereum.workspace = true
|
||||
reth-node-types.workspace = true
|
||||
|
||||
|
||||
eyre.workspace = true
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
use reth_chainspec::ChainSpecBuilder;
|
||||
use reth_node_ethereum::EthereumNode;
|
||||
use reth_node_types::NodeTypesWithDBAdapter;
|
||||
use reth_primitives::{Address, B256};
|
||||
use reth_provider::{
|
||||
providers::StaticFileProvider, AccountReader, BlockReader, BlockSource, HeaderProvider,
|
||||
@ -21,12 +23,13 @@ fn main() -> eyre::Result<()> {
|
||||
// Instantiate a provider factory for Ethereum mainnet using the provided DB.
|
||||
// TODO: Should the DB version include the spec so that you do not need to specify it here?
|
||||
let spec = ChainSpecBuilder::mainnet().build();
|
||||
let factory = ProviderFactory::new_with_database_path(
|
||||
db_path,
|
||||
spec.into(),
|
||||
Default::default(),
|
||||
StaticFileProvider::read_only(db_path.join("static_files"))?,
|
||||
)?;
|
||||
let factory =
|
||||
ProviderFactory::<NodeTypesWithDBAdapter<EthereumNode, _>>::new_with_database_path(
|
||||
db_path,
|
||||
spec.into(),
|
||||
Default::default(),
|
||||
StaticFileProvider::read_only(db_path.join("static_files"))?,
|
||||
)?;
|
||||
|
||||
// This call opens a RO transaction on the database. To write to the DB you'd need to call
|
||||
// the `provider_rw` function and look for the `Writer` variants of the traits.
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
use std::{path::Path, sync::Arc};
|
||||
|
||||
use reth::{
|
||||
api::NodeTypesWithDBAdapter,
|
||||
providers::{
|
||||
providers::{BlockchainProvider, StaticFileProvider},
|
||||
ProviderFactory,
|
||||
@ -23,7 +24,7 @@ use reth::{
|
||||
utils::open_db_read_only,
|
||||
};
|
||||
use reth_chainspec::ChainSpecBuilder;
|
||||
use reth_db::mdbx::DatabaseArguments;
|
||||
use reth_db::{mdbx::DatabaseArguments, DatabaseEnv};
|
||||
use reth_db_api::models::ClientVersion;
|
||||
|
||||
// Bringing up the RPC
|
||||
@ -33,7 +34,7 @@ use reth::rpc::builder::{
|
||||
// Configuring the network parts, ideally also wouldn't need to think about this.
|
||||
use myrpc_ext::{MyRpcExt, MyRpcExtApiServer};
|
||||
use reth::{blockchain_tree::noop::NoopBlockchainTree, tasks::TokioTaskExecutor};
|
||||
use reth_node_ethereum::EthEvmConfig;
|
||||
use reth_node_ethereum::{EthEvmConfig, EthereumNode};
|
||||
use reth_provider::test_utils::TestCanonStateSubscriptions;
|
||||
|
||||
// Custom rpc extension
|
||||
@ -49,7 +50,7 @@ async fn main() -> eyre::Result<()> {
|
||||
DatabaseArguments::new(ClientVersion::default()),
|
||||
)?);
|
||||
let spec = Arc::new(ChainSpecBuilder::mainnet().build());
|
||||
let factory = ProviderFactory::new(
|
||||
let factory = ProviderFactory::<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>::new(
|
||||
db.clone(),
|
||||
spec.clone(),
|
||||
StaticFileProvider::read_only(db_path.join("static_files"))?,
|
||||
|
||||
Reference in New Issue
Block a user