Skip to content
Snippets Groups Projects
Unverified Commit 2e39e052 authored by Bastian Köcher's avatar Bastian Köcher Committed by GitHub
Browse files

Improve pruning CLI documentation (#4810)

Closes: https://github.com/paritytech/polkadot-sdk/issues/4801

@andreclaro I hope this makes it more clear from the docs directly.
parent d91cbbd4
No related merge requests found
Pipeline #481500 waiting for manual action with stages
in 59 minutes
......@@ -17,7 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::error;
use clap::Args;
use clap::{builder::PossibleValue, Args, ValueEnum};
use sc_service::{BlocksPruning, PruningMode};
/// Parameters to define the pruning mode
......@@ -29,29 +29,24 @@ pub struct PruningParams {
/// should be pruned (ie, removed) from the database.
/// This setting can only be set on the first creation of the database. Every subsequent run
/// will load the pruning mode from the database and will error if the stored mode doesn't
/// match this CLI value. It is fine to drop this CLI flag for subsequent runs.
/// Possible values:
/// - archive: Keep the state of all blocks.
/// - 'archive-canonical' Keep only the state of finalized blocks.
/// - number Keep the state of the last number of finalized blocks.
/// match this CLI value. It is fine to drop this CLI flag for subsequent runs. The only
/// exception is that `<NUMBER>` can change between subsequent runs (increasing it will not
/// lead to restoring pruned state).
///
/// [default: 256]
#[arg(alias = "pruning", long, value_name = "PRUNING_MODE")]
#[arg(alias = "pruning", long, value_name = "PRUNING_MODE", value_enum)]
pub state_pruning: Option<DatabasePruningMode>,
/// Specify the blocks pruning mode.
///
/// This mode specifies when the block's body (including justifications)
/// should be pruned (ie, removed) from the database.
/// Possible values:
/// - 'archive' Keep all blocks.
/// - 'archive-canonical' Keep only finalized blocks.
/// - number
/// Keep the last `number` of finalized blocks.
#[arg(
alias = "keep-blocks",
long,
value_name = "PRUNING_MODE",
default_value = "archive-canonical"
default_value_t = DatabasePruningMode::ArchiveCanonical,
value_enum
)]
pub blocks_pruning: DatabasePruningMode,
}
......@@ -83,6 +78,26 @@ pub enum DatabasePruningMode {
Custom(u32),
}
impl ValueEnum for DatabasePruningMode {
fn value_variants<'a>() -> &'a [Self] {
&[Self::Archive, Self::ArchiveCanonical, Self::Custom(0)]
}
fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {
Some(match self {
Self::Archive => PossibleValue::new("archive").help("Keep the data of all blocks."),
Self::ArchiveCanonical => PossibleValue::new("archive-canonical")
.help("Keep only the data of finalized blocks."),
Self::Custom(_) => PossibleValue::new("<NUMBER>")
.help("Keep the data of the last <NUMBER> of finalized blocks."),
})
}
fn from_str(input: &str, _: bool) -> Result<Self, String> {
<Self as std::str::FromStr>::from_str(input)
}
}
impl std::str::FromStr for DatabasePruningMode {
type Err = String;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment