Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Prev Previous commit
Next Next commit
cli: Convert PruningModeClap into pruning modes
Signed-off-by: Alexandru Vasile <[email protected]>
  • Loading branch information
lexnv committed Dec 5, 2022
commit 7eb7956609c24b441bbe0fa95a23d41738d4007f
22 changes: 21 additions & 1 deletion client/cli/src/params/pruning_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl PruningParams {
/// This specifies when the block's data (either state via `--state-pruning`
/// or body via `--blocks-pruning`) should be pruned (ie, removed) from
/// the database.
#[derive(Clone)]
#[derive(Debug, Clone, PartialEq)]
enum PruningModeClap {
/// Keep the data of all blocks.
Archive,
Expand Down Expand Up @@ -132,3 +132,23 @@ impl clap::ValueEnum for PruningModeClap {
}
}
}

impl Into<PruningMode> for PruningModeClap {
fn into(self) -> PruningMode {
match self {
PruningModeClap::Archive => PruningMode::ArchiveAll,
PruningModeClap::ArchiveCanonical => PruningMode::ArchiveCanonical,
PruningModeClap::Custom(n) => PruningMode::blocks_pruning(n),
}
}
}

impl Into<BlocksPruning> for PruningModeClap {
fn into(self) -> BlocksPruning {
match self {
PruningModeClap::Archive => BlocksPruning::KeepAll,
PruningModeClap::ArchiveCanonical => BlocksPruning::KeepFinalized,
PruningModeClap::Custom(n) => BlocksPruning::Some(n),
}
}
}