reth_cli_commands/stage/
mod.rs1use std::sync::Arc;
4
5use crate::common::CliNodeTypes;
6use clap::{Parser, Subcommand};
7use reth_chainspec::{EthChainSpec, EthereumHardforks};
8use reth_cli::chainspec::ChainSpecParser;
9use reth_cli_runner::CliContext;
10use reth_evm::execute::BlockExecutorProvider;
11
12pub mod drop;
13pub mod dump;
14pub mod run;
15pub mod unwind;
16
17#[derive(Debug, Parser)]
19pub struct Command<C: ChainSpecParser> {
20 #[command(subcommand)]
21 command: Subcommands<C>,
22}
23
24#[derive(Subcommand, Debug)]
26pub enum Subcommands<C: ChainSpecParser> {
27 Run(run::Command<C>),
34 Drop(drop::Command<C>),
36 Dump(dump::Command<C>),
38 Unwind(unwind::Command<C>),
40}
41
42impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C> {
43 pub async fn execute<N, E, F>(self, ctx: CliContext, executor: F) -> eyre::Result<()>
45 where
46 N: CliNodeTypes<ChainSpec = C::ChainSpec>,
47 E: BlockExecutorProvider<Primitives = N::Primitives>,
48 F: FnOnce(Arc<C::ChainSpec>) -> E,
49 {
50 match self.command {
51 Subcommands::Run(command) => command.execute::<N, _, _>(ctx, executor).await,
52 Subcommands::Drop(command) => command.execute::<N>().await,
53 Subcommands::Dump(command) => command.execute::<N, _, _>(executor).await,
54 Subcommands::Unwind(command) => command.execute::<N>().await,
55 }
56 }
57}