Add a command to purge the relay chain only (#306)

* Add a command to purge the relay chain only

* WIP

* Update rococo-parachains/src/cli.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Move cli stuff to its own crate

* Copyright dates

* Test not working for some reason...

* WIP

* Revert "WIP"

This reverts commit f97cd63742c7df822e4a6e52a29db5e0f56b7bfa.

* Fix test to use provided relay chain

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Add hint about which database could not be purged

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Cecile Tonglet
2021-03-03 13:40:22 +01:00
committed by GitHub
parent fb649f19c2
commit e53a932fe4
42 changed files with 257 additions and 83 deletions
+12 -7
View File
@@ -1,4 +1,4 @@
// Copyright 2019 Parity Technologies (UK) Ltd.
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Cumulus is free software: you can redistribute it and/or modify
@@ -14,9 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use std::path::PathBuf;
use crate::chain_spec;
use sc_cli;
use std::path::PathBuf;
use structopt::StructOpt;
/// Sub-commands supported by the collator.
@@ -46,7 +46,7 @@ pub enum Subcommand {
ImportBlocks(sc_cli::ImportBlocksCmd),
/// Remove the whole chain.
PurgeChain(sc_cli::PurgeChainCmd),
PurgeChain(cumulus_cli::PurgeChainCmd),
/// Revert the chain to a previous state.
Revert(sc_cli::RevertCmd),
@@ -143,12 +143,17 @@ pub struct RelayChainCli {
}
impl RelayChainCli {
/// Create a new instance of `Self`.
/// Parse the relay chain CLI parameters using the para chain `Configuration`.
pub fn new<'a>(
base_path: Option<PathBuf>,
chain_id: Option<String>,
para_config: &sc_service::Configuration,
relay_chain_args: impl Iterator<Item = &'a String>,
) -> Self {
let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);
let chain_id = extension.map(|e| e.relay_chain.clone());
let base_path = para_config
.base_path
.as_ref()
.map(|x| x.path().join("polkadot"));
Self {
base_path,
chain_id,