reth_cli_commands/stage/
mod.rsuse std::sync::Arc;
use crate::common::CliNodeTypes;
use clap::{Parser, Subcommand};
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_cli::chainspec::ChainSpecParser;
use reth_cli_runner::CliContext;
use reth_eth_wire::NetPrimitivesFor;
use reth_evm::execute::BlockExecutorProvider;
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, P>(self, ctx: CliContext, executor: F) -> eyre::Result<()>
where
N: CliNodeTypes<ChainSpec = C::ChainSpec>,
E: BlockExecutorProvider<Primitives = N::Primitives>,
F: FnOnce(Arc<C::ChainSpec>) -> E,
P: NetPrimitivesFor<N::Primitives>,
{
match self.command {
Subcommands::Run(command) => command.execute::<N, _, _, P>(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,
}
}
}