reth_cli_commands/recover/
mod.rs

1//! `reth recover` command.
2
3use crate::common::CliNodeTypes;
4use clap::{Parser, Subcommand};
5use reth_chainspec::{EthChainSpec, EthereumHardforks};
6use reth_cli::chainspec::ChainSpecParser;
7use reth_cli_runner::CliContext;
8use std::sync::Arc;
9
10mod storage_tries;
11
12/// `reth recover` command
13#[derive(Debug, Parser)]
14pub struct Command<C: ChainSpecParser> {
15    #[command(subcommand)]
16    command: Subcommands<C>,
17}
18
19/// `reth recover` subcommands
20#[derive(Subcommand, Debug)]
21pub enum Subcommands<C: ChainSpecParser> {
22    /// Recover the node by deleting dangling storage tries.
23    StorageTries(storage_tries::Command<C>),
24}
25
26impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C> {
27    /// Execute `recover` command
28    pub async fn execute<N: CliNodeTypes<ChainSpec = C::ChainSpec>>(
29        self,
30        ctx: CliContext,
31    ) -> eyre::Result<()> {
32        match self.command {
33            Subcommands::StorageTries(command) => command.execute::<N>(ctx).await,
34        }
35    }
36}
37
38impl<C: ChainSpecParser> Command<C> {
39    /// Returns the underlying chain being used to run this command
40    pub fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
41        match &self.command {
42            Subcommands::StorageTries(command) => command.chain_spec(),
43        }
44    }
45}