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

Commit bd72413

Browse files
committed
Added doc and fixed warnings
1 parent b950f73 commit bd72413

19 files changed

+88
-65
lines changed

client/cli-derive/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
//! Configuration trait for a CLI based on substrate
1818
19-
extern crate proc_macro;
20-
2119
mod spec_factory;
2220
mod substrate_cli_params;
2321

client/cli/src/commands/build_spec_cmd.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
1616

17-
use log::info;
18-
use sc_network::config::build_multiaddr;
19-
use sc_service::{ChainSpec, ChainSpecExtension, Configuration, RuntimeGenesis};
20-
use structopt::StructOpt;
21-
2217
use crate::error;
2318
use crate::params::NodeKeyParams;
2419
use crate::params::SharedParams;
25-
use crate::SubstrateCLI;
2620
use crate::{substrate_cli_params, CliConfiguration};
21+
use log::info;
22+
use sc_network::config::build_multiaddr;
23+
use sc_service::{ChainSpecExtension, Configuration, RuntimeGenesis};
24+
use structopt::StructOpt;
2725

2826
/// The `build-spec` command used to build a specification.
2927
#[derive(Debug, StructOpt, Clone)]

client/cli/src/commands/check_block_cmd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
1616

1717
use sc_service::{
18-
ChainSpec, ChainSpecExtension, Configuration, Roles, RuntimeGenesis, ServiceBuilderCommand,
18+
ChainSpecExtension, Configuration, RuntimeGenesis, ServiceBuilderCommand,
1919
};
2020
use sp_runtime::generic::BlockId;
2121
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};

client/cli/src/commands/export_blocks_cmd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use crate::params::{BlockNumber, PruningParams, SharedParams};
1919
use crate::{substrate_cli_params, CliConfiguration};
2020
use log::info;
2121
use sc_service::{
22-
config::DatabaseConfig, ChainSpec, ChainSpecExtension, Configuration, PruningMode, Roles,
23-
RuntimeGenesis, ServiceBuilderCommand,
22+
config::DatabaseConfig, ChainSpecExtension, Configuration, RuntimeGenesis,
23+
ServiceBuilderCommand,
2424
};
2525
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
2626
use std::fmt::Debug;

client/cli/src/commands/import_blocks_cmd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::params::ImportParams;
1919
use crate::params::SharedParams;
2020
use crate::{substrate_cli_params, CliConfiguration};
2121
use sc_service::{
22-
ChainSpec, ChainSpecExtension, Configuration, Roles, RuntimeGenesis, ServiceBuilderCommand,
22+
ChainSpecExtension, Configuration, RuntimeGenesis, ServiceBuilderCommand,
2323
};
2424
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
2525
use std::fmt::Debug;

client/cli/src/commands/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,15 @@ use crate::params::SharedParams;
3333
use crate::CliConfiguration;
3434
use crate::Result;
3535
use crate::SubstrateCLI;
36-
use app_dirs::{AppDataType, AppInfo};
37-
use core::future::Future;
38-
use core::pin::Pin;
3936
use sc_client_api::execution_extensions::ExecutionStrategies;
4037
use sc_network::config::NodeKeyConfig;
4138
use sc_service::{
42-
config::DatabaseConfig, config::KeystoreConfig, config::NetworkConfiguration,
43-
config::WasmExecutionMethod, ChainSpec, ChainSpecExtension, Configuration, PruningMode, Roles,
44-
RuntimeGenesis, ServiceBuilderCommand,
39+
config::DatabaseConfig, config::WasmExecutionMethod, ChainSpec, ChainSpecExtension, PruningMode,
40+
Roles, RuntimeGenesis,
4541
};
4642
use sc_tracing::TracingReceiver;
47-
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
4843
use std::fmt::Debug;
4944
use std::path::PathBuf;
50-
use std::sync::Arc;
5145
use structopt::StructOpt;
5246

5347
/// All core commands that are provided by default.

client/cli/src/commands/purge_chain_cmd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::error;
1818
use crate::params::SharedParams;
1919
use crate::{substrate_cli_params, CliConfiguration};
2020
use sc_service::{
21-
config::DatabaseConfig, ChainSpec, ChainSpecExtension, Configuration, RuntimeGenesis,
21+
config::DatabaseConfig, ChainSpecExtension, Configuration, RuntimeGenesis,
2222
};
2323
use std::fmt::Debug;
2424
use std::fs;

client/cli/src/commands/revert_cmd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
1616

1717
use sc_service::{
18-
ChainSpec, ChainSpecExtension, Configuration, Roles, RuntimeGenesis, ServiceBuilderCommand,
18+
ChainSpecExtension, Configuration, RuntimeGenesis, ServiceBuilderCommand,
1919
};
2020
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
2121
use std::fmt::Debug;

client/cli/src/commands/runcmd.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,11 @@ use crate::params::NetworkConfigurationParams;
2121
use crate::params::SharedParams;
2222
use crate::params::TransactionPoolParams;
2323
use crate::substrate_cli_params;
24-
use crate::{CliConfiguration, SubstrateCLI};
24+
use crate::CliConfiguration;
2525
use regex::Regex;
26-
use sc_client_api::execution_extensions::ExecutionStrategies;
27-
use sc_network::config::NodeKeyConfig;
28-
use sc_service::{
29-
config::{
30-
DatabaseConfig, KeystoreConfig, NetworkConfiguration, TransactionPoolOptions,
31-
WasmExecutionMethod,
32-
},
33-
AbstractService, ChainSpec, ChainSpecExtension, Configuration, PruningMode, Roles,
34-
RuntimeGenesis,
35-
};
26+
use sc_service::{config::TransactionPoolOptions, ChainSpec, Roles};
3627
use sc_telemetry::TelemetryEndpoints;
37-
use sc_tracing::TracingReceiver;
38-
use std::fs;
39-
use std::future::Future;
4028
use std::net::SocketAddr;
41-
use std::path::PathBuf;
42-
use std::pin::Pin;
43-
use std::sync::Arc;
4429
use structopt::{clap::arg_enum, StructOpt};
4530

4631
arg_enum! {
@@ -242,6 +227,7 @@ pub struct RunCmd {
242227
#[structopt(long = "force-authoring")]
243228
pub force_authoring: bool,
244229

230+
#[allow(missing_docs)]
245231
#[structopt(flatten)]
246232
pub keystore_params: KeystoreParams,
247233
}

client/cli/src/config.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,27 @@ pub(crate) const NODE_NAME_MAX_LENGTH: usize = 32;
3838
/// default sub directory to store network config
3939
pub(crate) const DEFAULT_NETWORK_CONFIG_PATH: &'static str = "network";
4040

41+
/// A trait that allows converting an object to a Configuration
4142
pub trait CliConfiguration: Sized {
43+
/// Get the base path of the configuration (if any)
4244
fn get_base_path(&self) -> Result<Option<&PathBuf>>;
4345

46+
/// Returns `true` if the node is for development or not
4447
fn get_is_dev(&self) -> Result<bool> {
4548
Ok(false)
4649
}
4750

51+
/// Get the roles
4852
fn get_roles(&self, _is_dev: bool) -> Result<Roles> {
4953
Ok(Roles::FULL)
5054
}
5155

56+
/// Get the transaction pool options
5257
fn get_transaction_pool(&self) -> Result<TransactionPoolOptions> {
5358
Ok(Default::default())
5459
}
5560

61+
/// Get the network configuration
5662
fn get_network_config<G, E>(
5763
&self,
5864
_chain_spec: &ChainSpec<G, E>,
@@ -74,117 +80,143 @@ pub trait CliConfiguration: Sized {
7480
))
7581
}
7682

83+
/// Get the keystore configuration
7784
fn get_keystore_config(&self, _base_path: &PathBuf) -> Result<KeystoreConfig> {
7885
Ok(KeystoreConfig::InMemory)
7986
}
8087

88+
/// Get the database cache size (None for default)
8189
fn get_database_cache_size(&self) -> Result<Option<usize>> {
8290
Ok(Default::default())
8391
}
8492

93+
/// Get the database configuration
8594
fn get_database_config(
8695
&self,
8796
base_path: &PathBuf,
8897
cache_size: Option<usize>,
8998
) -> Result<DatabaseConfig>;
9099

100+
/// Get the state cache size
91101
fn get_state_cache_size(&self) -> Result<usize> {
92102
Ok(Default::default())
93103
}
94104

105+
/// Get the state cache child ratio (if any)
95106
fn get_state_cache_child_ratio(&self) -> Result<Option<usize>> {
96107
Ok(Default::default())
97108
}
98109

110+
/// Get the pruning mode
99111
fn get_pruning(&self, _is_dev: bool, _roles: Roles) -> Result<PruningMode> {
100112
Ok(Default::default())
101113
}
102114

115+
/// Get the chain spec
103116
fn get_chain_spec<C: SubstrateCLI<G, E>, G, E>(&self) -> Result<ChainSpec<G, E>>
104117
where
105118
G: RuntimeGenesis,
106119
E: ChainSpecExtension;
107120

121+
/// Get the name of the node
108122
fn get_node_name(&self) -> Result<String> {
109123
Ok(generate_node_name())
110124
}
111125

126+
/// Get the WASM execution method
112127
fn get_wasm_method(&self) -> Result<WasmExecutionMethod> {
113128
Ok(Default::default())
114129
}
115130

131+
/// Get the execution strategies
116132
fn get_execution_strategies(&self, _is_dev: bool) -> Result<ExecutionStrategies> {
117133
Ok(Default::default())
118134
}
119135

136+
/// Get the RPC HTTP address (`None` if disabled)
120137
fn get_rpc_http(&self) -> Result<Option<SocketAddr>> {
121138
Ok(Default::default())
122139
}
123140

141+
/// Get the RPC websocket address (`None` if disabled)
124142
fn get_rpc_ws(&self) -> Result<Option<SocketAddr>> {
125143
Ok(Default::default())
126144
}
127145

146+
/// Get the RPC websockets maximum connections (`None` if unlimited)
128147
fn get_rpc_ws_max_connections(&self) -> Result<Option<usize>> {
129148
Ok(Default::default())
130149
}
131150

151+
/// Get the RPC cors (`None` if disabled)
132152
fn get_rpc_cors(&self, _is_dev: bool) -> Result<Option<Vec<String>>> {
133153
Ok(Some(Vec::new()))
134154
}
135155

156+
/// Get the prometheus port (`None` if disabled)
136157
fn get_prometheus_port(&self) -> Result<Option<SocketAddr>> {
137158
Ok(Default::default())
138159
}
139160

161+
/// Get the telemetry endpoints (if any)
140162
fn get_telemetry_endpoints<G, E>(
141163
&self,
142164
chain_spec: &ChainSpec<G, E>,
143165
) -> Result<Option<TelemetryEndpoints>> {
144166
Ok(chain_spec.telemetry_endpoints().clone())
145167
}
146168

169+
/// Get the telemetry external transport
147170
fn get_telemetry_external_transport(&self) -> Result<Option<ExtTransport>> {
148171
Ok(Default::default())
149172
}
150173

174+
/// Get the default value for heap pages
151175
fn get_default_heap_pages(&self) -> Result<Option<u64>> {
152176
Ok(Default::default())
153177
}
154178

179+
/// Returns `Ok(true)` if offchain worker should be used
155180
fn get_offchain_worker(&self, _roles: Roles) -> Result<bool> {
156181
Ok(Default::default())
157182
}
158183

159-
/// set sentry mode (i.e. act as an authority but **never** actively participate)
184+
/// Get sentry mode (i.e. act as an authority but **never** actively participate)
160185
fn get_sentry_mode(&self) -> Result<bool> {
161186
Ok(Default::default())
162187
}
163188

189+
/// Returns `Ok(true)` if authoring should be forced
164190
fn get_force_authoring(&self) -> Result<bool> {
165191
Ok(Default::default())
166192
}
167193

194+
/// Returns `Ok(true)` if grandpa should be disabled
168195
fn get_disable_grandpa(&self) -> Result<bool> {
169196
Ok(Default::default())
170197
}
171198

199+
/// Get the development key seed from the current object
172200
fn get_dev_key_seed(&self, _is_dev: bool) -> Result<Option<String>> {
173201
Ok(Default::default())
174202
}
175203

204+
/// Get the tracing targets from the current object (if any)
176205
fn get_tracing_targets(&self) -> Result<Option<String>> {
177206
Ok(Default::default())
178207
}
179208

209+
/// Get the TracingReceiver value from the current object
180210
fn get_tracing_receiver(&self) -> Result<sc_tracing::TracingReceiver> {
181211
Ok(Default::default())
182212
}
183213

214+
/// Get the node key from the current object
184215
fn get_node_key(&self, _net_config_dir: &PathBuf) -> Result<NodeKeyConfig> {
185216
Ok(Default::default())
186217
}
187218

219+
/// Create a Configuration object from the current object
188220
fn create_configuration<C: SubstrateCLI<G, E>, G, E>(
189221
&self,
190222
task_executor: Arc<dyn Fn(Pin<Box<dyn Future<Output = ()> + Send>>) + Send + Sync>,

0 commit comments

Comments
 (0)