reth_cli_commands/stage/
mod.rsuse std::sync::Arc;
use clap::{Parser, Subcommand};
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_cli::chainspec::ChainSpecParser;
use reth_cli_runner::CliContext;
use reth_evm::execute::BlockExecutorProvider;
use reth_node_builder::NodeTypesWithEngine;
pub mod drop;
pub mod dump;
pub mod run;
pub mod unwind;
#[derive(Debug, Parser)]
pub struct Command<C: ChainSpecParser> {
#[command(subcommand)]
command: Subcommands<C>,
}
#[derive(Subcommand, Debug)]
pub enum Subcommands<C: ChainSpecParser> {
Run(run::Command<C>),
Drop(drop::Command<C>),
Dump(dump::Command<C>),
Unwind(unwind::Command<C>),
}
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C> {
pub async fn execute<N, E, F>(self, ctx: CliContext, executor: F) -> eyre::Result<()>
where
N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>,
E: BlockExecutorProvider,
F: FnOnce(Arc<C::ChainSpec>) -> E,
{
match self.command {
Subcommands::Run(command) => command.execute::<N, _, _>(ctx, executor).await,
Subcommands::Drop(command) => command.execute::<N>().await,
Subcommands::Dump(command) => command.execute::<N, _, _>(executor).await,
Subcommands::Unwind(command) => command.execute::<N>().await,
}
}
}