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: Rename to DatabasePruningMode
Signed-off-by: Alexandru Vasile <[email protected]>
  • Loading branch information
lexnv committed Dec 5, 2022
commit 9cf6f5ecb8e96eaac508ccd535fd28a06c29ba4b
24 changes: 12 additions & 12 deletions client/cli/src/params/pruning_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ pub struct PruningParams {
/// This mode specifies when the block's state (ie, storage)
/// should be pruned (ie, removed) from the database.
#[arg(alias = "pruning", long, value_name = "PRUNING_MODE", default_value = "256")]
pub state_pruning: PruningModeClap,
pub state_pruning: DatabasePruningMode,
/// Specify the blocks pruning mode.
///
/// This mode specifies when the block's body (including justifications)
/// should be pruned (ie, removed) from the database.
#[arg(alias = "keep-blocks", long, value_name = "COUNT", default_value = "archive-canonical")]
pub blocks_pruning: PruningModeClap,
pub blocks_pruning: DatabasePruningMode,
}

impl PruningParams {
Expand All @@ -55,7 +55,7 @@ impl PruningParams {
/// or body via `--blocks-pruning`) should be pruned (ie, removed) from
/// the database.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum PruningModeClap {
pub enum DatabasePruningMode {
/// Keep the data of all blocks.
Archive,
/// Keep only the data of finalized blocks.
Expand All @@ -64,7 +64,7 @@ pub enum PruningModeClap {
Custom(u32),
}

impl clap::ValueEnum for PruningModeClap {
impl clap::ValueEnum for DatabasePruningMode {
fn value_variants<'a>() -> &'a [Self] {
&[
Self::Archive,
Expand Down Expand Up @@ -95,22 +95,22 @@ impl clap::ValueEnum for PruningModeClap {
}
}

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

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