Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit e670750

Browse files
committed
Merge remote-tracking branch 'origin/master' into bkchr-aura-the-long-way
2 parents 8c1f788 + 5cdbd7c commit e670750

File tree

45 files changed

+491
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+491
-275
lines changed

Cargo.lock

Lines changed: 238 additions & 189 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[workspace]
22
members = [
3+
"cli",
34
"client/consensus/aura",
45
"client/consensus/common",
56
"client/consensus/relay-chain",

cli/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "cumulus-cli"
3+
version = "0.1.0"
4+
authors = ["Parity Technologies <[email protected]>"]
5+
edition = "2018"
6+
7+
[dependencies]
8+
structopt = "0.3.3"
9+
10+
# Substrate dependencies
11+
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
12+
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" }

cli/src/lib.rs

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// Copyright 2021 Parity Technologies (UK) Ltd.
2+
// This file is part of Cumulus.
3+
4+
// Cumulus is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// Cumulus is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
16+
17+
//! Cumulus CLI library.
18+
19+
#![warn(missing_docs)]
20+
21+
use sc_cli;
22+
use std::{
23+
fs,
24+
io::{self, Write},
25+
};
26+
use structopt::StructOpt;
27+
28+
/// The `purge-chain` command used to remove the whole chain: the parachain and the relaychain.
29+
#[derive(Debug, StructOpt)]
30+
pub struct PurgeChainCmd {
31+
/// The base struct of the purge-chain command.
32+
#[structopt(flatten)]
33+
pub base: sc_cli::PurgeChainCmd,
34+
35+
/// Only delete the para chain database
36+
#[structopt(long, aliases = &["para"])]
37+
pub parachain: bool,
38+
39+
/// Only delete the relay chain database
40+
#[structopt(long, aliases = &["relay"])]
41+
pub relaychain: bool,
42+
}
43+
44+
impl PurgeChainCmd {
45+
/// Run the purge command
46+
pub fn run(
47+
&self,
48+
para_config: sc_service::Configuration,
49+
relay_config: sc_service::Configuration,
50+
) -> sc_cli::Result<()> {
51+
let databases = match (self.parachain, self.relaychain) {
52+
(true, true) | (false, false) => vec![
53+
("parachain", para_config.database),
54+
("relaychain", relay_config.database),
55+
],
56+
(true, false) => vec![("parachain", para_config.database)],
57+
(false, true) => vec![("relaychain", relay_config.database)],
58+
};
59+
60+
let db_paths = databases
61+
.iter()
62+
.map(|(chain_label, database)| {
63+
database.path().ok_or_else(|| sc_cli::Error::Input(format!(
64+
"Cannot purge custom database implementation of: {}",
65+
chain_label,
66+
)))
67+
})
68+
.collect::<sc_cli::Result<Vec<_>>>()?;
69+
70+
if !self.base.yes {
71+
for db_path in &db_paths {
72+
println!("{}", db_path.display());
73+
}
74+
print!("Are you sure to remove? [y/N]: ");
75+
io::stdout().flush().expect("failed to flush stdout");
76+
77+
let mut input = String::new();
78+
io::stdin().read_line(&mut input)?;
79+
let input = input.trim();
80+
81+
match input.chars().nth(0) {
82+
Some('y') | Some('Y') => {}
83+
_ => {
84+
println!("Aborted");
85+
return Ok(());
86+
}
87+
}
88+
}
89+
90+
for db_path in &db_paths {
91+
match fs::remove_dir_all(&db_path) {
92+
Ok(_) => {
93+
println!("{:?} removed.", &db_path);
94+
}
95+
Err(ref err) if err.kind() == io::ErrorKind::NotFound => {
96+
eprintln!("{:?} did not exist.", &db_path);
97+
}
98+
Err(err) => return Err(err.into()),
99+
}
100+
}
101+
102+
Ok(())
103+
}
104+
}
105+
106+
impl sc_cli::CliConfiguration for PurgeChainCmd {
107+
fn shared_params(&self) -> &sc_cli::SharedParams {
108+
&self.base.shared_params
109+
}
110+
111+
fn database_params(&self) -> Option<&sc_cli::DatabaseParams> {
112+
Some(&self.base.database_params)
113+
}
114+
}

client/collator/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 Parity Technologies (UK) Ltd.
1+
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
22
// This file is part of Cumulus.
33

44
// Substrate is free software: you can redistribute it and/or modify

client/consensus/common/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 Parity Technologies (UK) Ltd.
1+
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
22
// This file is part of Cumulus.
33

44
// Cumulus is free software: you can redistribute it and/or modify

client/consensus/relay-chain/src/import_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 Parity Technologies (UK) Ltd.
1+
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
22
// This file is part of Cumulus.
33

44
// Cumulus is free software: you can redistribute it and/or modify

client/network/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 Parity Technologies (UK) Ltd.
1+
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
22
// This file is part of Polkadot.
33

44
// Polkadot is free software: you can redistribute it and/or modify

client/network/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2020 Parity Technologies (UK) Ltd.
1+
// Copyright 2020-2021 Parity Technologies (UK) Ltd.
22
// This file is part of Polkadot.
33

44
// Polkadot is free software: you can redistribute it and/or modify

client/network/src/wait_on_relay_chain_block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2020 Parity Technologies (UK) Ltd.
1+
// Copyright 2020-2021 Parity Technologies (UK) Ltd.
22
// This file is part of Polkadot.
33

44
// Polkadot is free software: you can redistribute it and/or modify

0 commit comments

Comments
 (0)