forest/cli/subcommands/chain_cmd/
prune.rs

1// Copyright 2019-2025 ChainSafe Systems
2// SPDX-License-Identifier: Apache-2.0, MIT
3
4use crate::rpc::{self, RpcMethodExt, chain::ChainPruneSnapshot};
5use clap::Subcommand;
6use std::time::Duration;
7
8/// Prune chain database
9#[derive(Debug, Subcommand)]
10pub enum ChainPruneCommands {
11    /// Run snapshot GC
12    Snap {
13        /// Do not block until GC is completed
14        #[arg(long)]
15        no_wait: bool,
16    },
17}
18
19impl ChainPruneCommands {
20    pub async fn run(self, client: rpc::Client) -> anyhow::Result<()> {
21        match self {
22            Self::Snap { no_wait } => {
23                client
24                    .call(ChainPruneSnapshot::request((!no_wait,))?.with_timeout(Duration::MAX))
25                    .await?;
26            }
27        }
28
29        Ok(())
30    }
31}