mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(tree): migrate tree externals to ProviderFactory (#5531)
This commit is contained in:
@ -142,15 +142,15 @@ impl Command {
|
||||
|
||||
// initialize the database
|
||||
let db = Arc::new(init_db(db_path, self.db.log_level)?);
|
||||
let provider_factory = ProviderFactory::new(Arc::clone(&db), Arc::clone(&self.chain));
|
||||
|
||||
let consensus: Arc<dyn Consensus> = Arc::new(BeaconConsensus::new(Arc::clone(&self.chain)));
|
||||
|
||||
// configure blockchain tree
|
||||
let tree_externals = TreeExternals::new(
|
||||
Arc::clone(&db),
|
||||
provider_factory.clone(),
|
||||
Arc::clone(&consensus),
|
||||
Factory::new(self.chain.clone()),
|
||||
Arc::clone(&self.chain),
|
||||
);
|
||||
let tree = BlockchainTree::new(tree_externals, BlockchainTreeConfig::default(), None)?;
|
||||
let blockchain_tree = ShareableBlockchainTree::new(tree);
|
||||
@ -159,8 +159,8 @@ impl Command {
|
||||
let best_block =
|
||||
self.lookup_best_block(Arc::clone(&db)).wrap_err("the head block is missing")?;
|
||||
|
||||
let factory = ProviderFactory::new(Arc::clone(&db), Arc::clone(&self.chain));
|
||||
let blockchain_db = BlockchainProvider::new(factory.clone(), blockchain_tree.clone())?;
|
||||
let blockchain_db =
|
||||
BlockchainProvider::new(provider_factory.clone(), blockchain_tree.clone())?;
|
||||
let blob_store = InMemoryBlobStore::default();
|
||||
|
||||
let validator = TransactionValidationTaskExecutor::eth_builder(Arc::clone(&self.chain))
|
||||
@ -278,7 +278,7 @@ impl Command {
|
||||
debug!(target: "reth::cli", ?state, "Executed block");
|
||||
|
||||
// Attempt to insert new block without committing
|
||||
let provider_rw = factory.provider_rw()?;
|
||||
let provider_rw = provider_factory.provider_rw()?;
|
||||
provider_rw.append_blocks_with_bundle_state(
|
||||
Vec::from([block_with_senders]),
|
||||
state,
|
||||
|
||||
@ -259,6 +259,16 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
|
||||
let db = Arc::new(init_db(&db_path, self.db.log_level)?.with_metrics());
|
||||
info!(target: "reth::cli", "Database opened");
|
||||
|
||||
// configure snapshotter
|
||||
let snapshotter = reth_snapshot::Snapshotter::new(
|
||||
db.clone(),
|
||||
data_dir.snapshots_path(),
|
||||
self.chain.clone(),
|
||||
self.chain.snapshot_block_interval,
|
||||
)?;
|
||||
let provider_factory = ProviderFactory::new(Arc::clone(&db), Arc::clone(&self.chain))
|
||||
.with_snapshots(data_dir.snapshots_path(), snapshotter.highest_snapshot_receiver());
|
||||
|
||||
self.start_metrics_endpoint(prometheus_handle, Arc::clone(&db)).await?;
|
||||
|
||||
debug!(target: "reth::cli", chain=%self.chain.chain, genesis=?self.chain.genesis_hash(), "Initializing genesis");
|
||||
@ -281,10 +291,9 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
|
||||
|
||||
// configure blockchain tree
|
||||
let tree_externals = TreeExternals::new(
|
||||
Arc::clone(&db),
|
||||
provider_factory.clone(),
|
||||
Arc::clone(&consensus),
|
||||
Factory::new(self.chain.clone()),
|
||||
Arc::clone(&self.chain),
|
||||
);
|
||||
let tree = BlockchainTree::new(
|
||||
tree_externals,
|
||||
@ -299,18 +308,8 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
|
||||
// fetch the head block from the database
|
||||
let head = self.lookup_head(Arc::clone(&db)).wrap_err("the head block is missing")?;
|
||||
|
||||
// configure snapshotter
|
||||
let snapshotter = reth_snapshot::Snapshotter::new(
|
||||
db.clone(),
|
||||
data_dir.snapshots_path(),
|
||||
self.chain.clone(),
|
||||
self.chain.snapshot_block_interval,
|
||||
)?;
|
||||
|
||||
// setup the blockchain provider
|
||||
let factory = ProviderFactory::new(Arc::clone(&db), Arc::clone(&self.chain))
|
||||
.with_snapshots(data_dir.snapshots_path(), snapshotter.highest_snapshot_receiver());
|
||||
let blockchain_db = BlockchainProvider::new(factory, blockchain_tree.clone())?;
|
||||
let blockchain_db = BlockchainProvider::new(provider_factory, blockchain_tree.clone())?;
|
||||
let blob_store = InMemoryBlobStore::default();
|
||||
let validator = TransactionValidationTaskExecutor::eth_builder(Arc::clone(&self.chain))
|
||||
.with_head_timestamp(head.timestamp)
|
||||
|
||||
Reference in New Issue
Block a user