This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
cli: Improve pruning documentation #12819
Merged
Merged
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7ece645
cli: Improve pruning documentation
lexnv fdbc9a0
cli: Keep `finalized` notation and remove `canonical` one
lexnv 804aff6
cli: Fix cargo doc
lexnv eb579bc
cli: `PruningModeClap` IR enum
lexnv 7eb7956
cli: Convert PruningModeClap into pruning modes
lexnv 8da7e10
cli: Use `PruningModeClap`
lexnv 9cf6f5e
cli: Rename to `DatabasePruningMode`
lexnv 9379757
cli: Implement `FromStr` instead of `clap::ValueEnum`
lexnv 5356629
Update client/cli/src/params/pruning_params.rs
lexnv f25b491
Fix clippy
lexnv e3ffe3e
cli: Add option documentation back
lexnv a4e88bf
Merge remote-tracking branch 'origin/master' into lexnv/cli_db_docume…
lexnv aee8844
Apply suggestions from code review
bkchr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,21 +23,30 @@ use sc_service::{BlocksPruning, PruningMode}; | |||||||||||||||||||||
| /// Parameters to define the pruning mode | ||||||||||||||||||||||
| #[derive(Debug, Clone, PartialEq, Args)] | ||||||||||||||||||||||
| pub struct PruningParams { | ||||||||||||||||||||||
| /// Specify the state pruning mode, a number of blocks to keep or 'archive'. | ||||||||||||||||||||||
| /// Specify the state pruning mode. | ||||||||||||||||||||||
| /// | ||||||||||||||||||||||
| /// Default is to keep only the last 256 blocks, | ||||||||||||||||||||||
| /// otherwise, the state can be kept for all of the blocks (i.e 'archive'), | ||||||||||||||||||||||
| /// or for all of the canonical blocks (i.e 'archive-canonical'). | ||||||||||||||||||||||
| /// This mode specifies when the block's state (ie, storage) | ||||||||||||||||||||||
| /// should be pruned (ie, removed) from the database. | ||||||||||||||||||||||
| /// | ||||||||||||||||||||||
| /// Options available: | ||||||||||||||||||||||
| /// '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. | ||||||||||||||||||||||
| /// | ||||||||||||||||||||||
| /// The default option is to keep the last 256 blocks (number == 256). | ||||||||||||||||||||||
bkchr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||
| #[arg(alias = "pruning", long, value_name = "PRUNING_MODE")] | ||||||||||||||||||||||
| pub state_pruning: Option<String>, | ||||||||||||||||||||||
|
||||||||||||||||||||||
| /// Options available: | |
| /// '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. | |
| /// | |
| /// The default option is to keep the last 256 blocks (number == 256). | |
| #[arg(alias = "pruning", long, value_name = "PRUNING_MODE")] | |
| pub state_pruning: Option<String>, | |
| #[arg(alias = "pruning", long, value_name = "PRUNING_MODE", default = "256")] | |
| pub state_pruning: PruningMode, |
Then add the following enum:
enum PruningMode {
Archive,
ArchiveCanonical,
Custom(u32),
}
impl clap::ValueEnum for PruningMode {
.. impl the enum
}
Contributor
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that does make sense! Thanks for the suggestion!
One problem with ValueEnum is that its happy with unit only enum variants. This is related to the value_variants that requires us to state the expected values. If the Custom(32) is omitted, the default value of "256" cannot be provided anymore.
To overcome this I've changed the ValueEnum to FromStr.
Let me know what you think of it
lexnv marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
lexnv marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.