mirror of
https://github.com/pezkuwichain/pezkuwi-runtime-templates.git
synced 2026-04-22 15:58:01 +00:00
cargo fmt on plain-cumulus template
This commit is contained in:
+157
-162
@@ -5,97 +5,95 @@ use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
|
||||
use log::info;
|
||||
use parachain_template_runtime::Block;
|
||||
use sc_cli::{
|
||||
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
|
||||
NetworkParams, Result, SharedParams, SubstrateCli,
|
||||
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
|
||||
NetworkParams, Result, SharedParams, SubstrateCli,
|
||||
};
|
||||
use sc_service::config::{BasePath, PrometheusConfig};
|
||||
use sp_runtime::traits::AccountIdConversion;
|
||||
|
||||
use crate::{
|
||||
chain_spec,
|
||||
cli::{Cli, RelayChainCli, Subcommand},
|
||||
service::new_partial,
|
||||
chain_spec,
|
||||
cli::{Cli, RelayChainCli, Subcommand},
|
||||
service::new_partial,
|
||||
};
|
||||
|
||||
fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
||||
Ok(match id {
|
||||
"dev" => Box::new(chain_spec::development_config()),
|
||||
"template-rococo" => Box::new(chain_spec::local_testnet_config()),
|
||||
"" | "local" => Box::new(chain_spec::local_testnet_config()),
|
||||
path => Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
|
||||
})
|
||||
Ok(match id {
|
||||
"dev" => Box::new(chain_spec::development_config()),
|
||||
"template-rococo" => Box::new(chain_spec::local_testnet_config()),
|
||||
"" | "local" => Box::new(chain_spec::local_testnet_config()),
|
||||
path => Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
|
||||
})
|
||||
}
|
||||
|
||||
impl SubstrateCli for Cli {
|
||||
fn impl_name() -> String {
|
||||
"Parachain Collator Template".into()
|
||||
}
|
||||
fn impl_name() -> String {
|
||||
"Parachain Collator Template".into()
|
||||
}
|
||||
|
||||
fn impl_version() -> String {
|
||||
env!("SUBSTRATE_CLI_IMPL_VERSION").into()
|
||||
}
|
||||
fn impl_version() -> String {
|
||||
env!("SUBSTRATE_CLI_IMPL_VERSION").into()
|
||||
}
|
||||
|
||||
fn description() -> String {
|
||||
format!(
|
||||
"Parachain Collator Template\n\nThe command-line arguments provided first will be \
|
||||
passed to the parachain node, while the arguments provided after -- will be passed \
|
||||
to the relay chain node.\n\n\
|
||||
{} <parachain-args> -- <relay-chain-args>",
|
||||
Self::executable_name()
|
||||
)
|
||||
}
|
||||
fn description() -> String {
|
||||
format!(
|
||||
"Parachain Collator Template\n\nThe command-line arguments provided first will be \
|
||||
passed to the parachain node, while the arguments provided after -- will be passed \
|
||||
to the relay chain node.\n\n{} <parachain-args> -- <relay-chain-args>",
|
||||
Self::executable_name()
|
||||
)
|
||||
}
|
||||
|
||||
fn author() -> String {
|
||||
env!("CARGO_PKG_AUTHORS").into()
|
||||
}
|
||||
fn author() -> String {
|
||||
env!("CARGO_PKG_AUTHORS").into()
|
||||
}
|
||||
|
||||
fn support_url() -> String {
|
||||
"https://github.com/paritytech/polkadot-sdk/issues/new".into()
|
||||
}
|
||||
fn support_url() -> String {
|
||||
"https://github.com/paritytech/polkadot-sdk/issues/new".into()
|
||||
}
|
||||
|
||||
fn copyright_start_year() -> i32 {
|
||||
2020
|
||||
}
|
||||
fn copyright_start_year() -> i32 {
|
||||
2020
|
||||
}
|
||||
|
||||
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
|
||||
load_spec(id)
|
||||
}
|
||||
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
|
||||
load_spec(id)
|
||||
}
|
||||
}
|
||||
|
||||
impl SubstrateCli for RelayChainCli {
|
||||
fn impl_name() -> String {
|
||||
"Parachain Collator Template".into()
|
||||
}
|
||||
fn impl_name() -> String {
|
||||
"Parachain Collator Template".into()
|
||||
}
|
||||
|
||||
fn impl_version() -> String {
|
||||
env!("SUBSTRATE_CLI_IMPL_VERSION").into()
|
||||
}
|
||||
fn impl_version() -> String {
|
||||
env!("SUBSTRATE_CLI_IMPL_VERSION").into()
|
||||
}
|
||||
|
||||
fn description() -> String {
|
||||
format!(
|
||||
"Parachain Collator Template\n\nThe command-line arguments provided first will be \
|
||||
passed to the parachain node, while the arguments provided after -- will be passed \
|
||||
to the relay chain node.\n\n\
|
||||
{} <parachain-args> -- <relay-chain-args>",
|
||||
Self::executable_name()
|
||||
)
|
||||
}
|
||||
fn description() -> String {
|
||||
format!(
|
||||
"Parachain Collator Template\n\nThe command-line arguments provided first will be \
|
||||
passed to the parachain node, while the arguments provided after -- will be passed \
|
||||
to the relay chain node.\n\n{} <parachain-args> -- <relay-chain-args>",
|
||||
Self::executable_name()
|
||||
)
|
||||
}
|
||||
|
||||
fn author() -> String {
|
||||
env!("CARGO_PKG_AUTHORS").into()
|
||||
}
|
||||
fn author() -> String {
|
||||
env!("CARGO_PKG_AUTHORS").into()
|
||||
}
|
||||
|
||||
fn support_url() -> String {
|
||||
"https://github.com/paritytech/polkadot-sdk/issues/new".into()
|
||||
}
|
||||
fn support_url() -> String {
|
||||
"https://github.com/paritytech/polkadot-sdk/issues/new".into()
|
||||
}
|
||||
|
||||
fn copyright_start_year() -> i32 {
|
||||
2020
|
||||
}
|
||||
fn copyright_start_year() -> i32 {
|
||||
2020
|
||||
}
|
||||
|
||||
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
|
||||
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)
|
||||
}
|
||||
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
|
||||
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! construct_async_run {
|
||||
@@ -111,9 +109,9 @@ macro_rules! construct_async_run {
|
||||
|
||||
/// Parse command line arguments into service configuration.
|
||||
pub fn run() -> Result<()> {
|
||||
let cli = Cli::from_args();
|
||||
let cli = Cli::from_args();
|
||||
|
||||
match &cli.subcommand {
|
||||
match &cli.subcommand {
|
||||
Some(Subcommand::BuildSpec(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
|
||||
@@ -269,126 +267,123 @@ pub fn run() -> Result<()> {
|
||||
}
|
||||
|
||||
impl DefaultConfigurationValues for RelayChainCli {
|
||||
fn p2p_listen_port() -> u16 {
|
||||
30334
|
||||
}
|
||||
fn p2p_listen_port() -> u16 {
|
||||
30334
|
||||
}
|
||||
|
||||
fn rpc_listen_port() -> u16 {
|
||||
9945
|
||||
}
|
||||
fn rpc_listen_port() -> u16 {
|
||||
9945
|
||||
}
|
||||
|
||||
fn prometheus_listen_port() -> u16 {
|
||||
9616
|
||||
}
|
||||
fn prometheus_listen_port() -> u16 {
|
||||
9616
|
||||
}
|
||||
}
|
||||
|
||||
impl CliConfiguration<Self> for RelayChainCli {
|
||||
fn shared_params(&self) -> &SharedParams {
|
||||
self.base.base.shared_params()
|
||||
}
|
||||
fn shared_params(&self) -> &SharedParams {
|
||||
self.base.base.shared_params()
|
||||
}
|
||||
|
||||
fn import_params(&self) -> Option<&ImportParams> {
|
||||
self.base.base.import_params()
|
||||
}
|
||||
fn import_params(&self) -> Option<&ImportParams> {
|
||||
self.base.base.import_params()
|
||||
}
|
||||
|
||||
fn network_params(&self) -> Option<&NetworkParams> {
|
||||
self.base.base.network_params()
|
||||
}
|
||||
fn network_params(&self) -> Option<&NetworkParams> {
|
||||
self.base.base.network_params()
|
||||
}
|
||||
|
||||
fn keystore_params(&self) -> Option<&KeystoreParams> {
|
||||
self.base.base.keystore_params()
|
||||
}
|
||||
fn keystore_params(&self) -> Option<&KeystoreParams> {
|
||||
self.base.base.keystore_params()
|
||||
}
|
||||
|
||||
fn base_path(&self) -> Result<Option<BasePath>> {
|
||||
Ok(self
|
||||
.shared_params()
|
||||
.base_path()?
|
||||
.or_else(|| self.base_path.clone().map(Into::into)))
|
||||
}
|
||||
fn base_path(&self) -> Result<Option<BasePath>> {
|
||||
Ok(self.shared_params().base_path()?.or_else(|| self.base_path.clone().map(Into::into)))
|
||||
}
|
||||
|
||||
fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
|
||||
self.base.base.rpc_addr(default_listen_port)
|
||||
}
|
||||
fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
|
||||
self.base.base.rpc_addr(default_listen_port)
|
||||
}
|
||||
|
||||
fn prometheus_config(
|
||||
&self,
|
||||
default_listen_port: u16,
|
||||
chain_spec: &Box<dyn ChainSpec>,
|
||||
) -> Result<Option<PrometheusConfig>> {
|
||||
self.base.base.prometheus_config(default_listen_port, chain_spec)
|
||||
}
|
||||
fn prometheus_config(
|
||||
&self,
|
||||
default_listen_port: u16,
|
||||
chain_spec: &Box<dyn ChainSpec>,
|
||||
) -> Result<Option<PrometheusConfig>> {
|
||||
self.base.base.prometheus_config(default_listen_port, chain_spec)
|
||||
}
|
||||
|
||||
fn init<F>(
|
||||
&self,
|
||||
_support_url: &String,
|
||||
_impl_version: &String,
|
||||
_logger_hook: F,
|
||||
_config: &sc_service::Configuration,
|
||||
) -> Result<()>
|
||||
where
|
||||
F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration),
|
||||
{
|
||||
unreachable!("PolkadotCli is never initialized; qed");
|
||||
}
|
||||
fn init<F>(
|
||||
&self,
|
||||
_support_url: &String,
|
||||
_impl_version: &String,
|
||||
_logger_hook: F,
|
||||
_config: &sc_service::Configuration,
|
||||
) -> Result<()>
|
||||
where
|
||||
F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration),
|
||||
{
|
||||
unreachable!("PolkadotCli is never initialized; qed");
|
||||
}
|
||||
|
||||
fn chain_id(&self, is_dev: bool) -> Result<String> {
|
||||
let chain_id = self.base.base.chain_id(is_dev)?;
|
||||
fn chain_id(&self, is_dev: bool) -> Result<String> {
|
||||
let chain_id = self.base.base.chain_id(is_dev)?;
|
||||
|
||||
Ok(if chain_id.is_empty() { self.chain_id.clone().unwrap_or_default() } else { chain_id })
|
||||
}
|
||||
Ok(if chain_id.is_empty() { self.chain_id.clone().unwrap_or_default() } else { chain_id })
|
||||
}
|
||||
|
||||
fn role(&self, is_dev: bool) -> Result<sc_service::Role> {
|
||||
self.base.base.role(is_dev)
|
||||
}
|
||||
fn role(&self, is_dev: bool) -> Result<sc_service::Role> {
|
||||
self.base.base.role(is_dev)
|
||||
}
|
||||
|
||||
fn transaction_pool(&self, is_dev: bool) -> Result<sc_service::config::TransactionPoolOptions> {
|
||||
self.base.base.transaction_pool(is_dev)
|
||||
}
|
||||
fn transaction_pool(&self, is_dev: bool) -> Result<sc_service::config::TransactionPoolOptions> {
|
||||
self.base.base.transaction_pool(is_dev)
|
||||
}
|
||||
|
||||
fn trie_cache_maximum_size(&self) -> Result<Option<usize>> {
|
||||
self.base.base.trie_cache_maximum_size()
|
||||
}
|
||||
fn trie_cache_maximum_size(&self) -> Result<Option<usize>> {
|
||||
self.base.base.trie_cache_maximum_size()
|
||||
}
|
||||
|
||||
fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {
|
||||
self.base.base.rpc_methods()
|
||||
}
|
||||
fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {
|
||||
self.base.base.rpc_methods()
|
||||
}
|
||||
|
||||
fn rpc_max_connections(&self) -> Result<u32> {
|
||||
self.base.base.rpc_max_connections()
|
||||
}
|
||||
fn rpc_max_connections(&self) -> Result<u32> {
|
||||
self.base.base.rpc_max_connections()
|
||||
}
|
||||
|
||||
fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {
|
||||
self.base.base.rpc_cors(is_dev)
|
||||
}
|
||||
fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {
|
||||
self.base.base.rpc_cors(is_dev)
|
||||
}
|
||||
|
||||
fn default_heap_pages(&self) -> Result<Option<u64>> {
|
||||
self.base.base.default_heap_pages()
|
||||
}
|
||||
fn default_heap_pages(&self) -> Result<Option<u64>> {
|
||||
self.base.base.default_heap_pages()
|
||||
}
|
||||
|
||||
fn force_authoring(&self) -> Result<bool> {
|
||||
self.base.base.force_authoring()
|
||||
}
|
||||
fn force_authoring(&self) -> Result<bool> {
|
||||
self.base.base.force_authoring()
|
||||
}
|
||||
|
||||
fn disable_grandpa(&self) -> Result<bool> {
|
||||
self.base.base.disable_grandpa()
|
||||
}
|
||||
fn disable_grandpa(&self) -> Result<bool> {
|
||||
self.base.base.disable_grandpa()
|
||||
}
|
||||
|
||||
fn max_runtime_instances(&self) -> Result<Option<usize>> {
|
||||
self.base.base.max_runtime_instances()
|
||||
}
|
||||
fn max_runtime_instances(&self) -> Result<Option<usize>> {
|
||||
self.base.base.max_runtime_instances()
|
||||
}
|
||||
|
||||
fn announce_block(&self) -> Result<bool> {
|
||||
self.base.base.announce_block()
|
||||
}
|
||||
fn announce_block(&self) -> Result<bool> {
|
||||
self.base.base.announce_block()
|
||||
}
|
||||
|
||||
fn telemetry_endpoints(
|
||||
&self,
|
||||
chain_spec: &Box<dyn ChainSpec>,
|
||||
) -> Result<Option<sc_telemetry::TelemetryEndpoints>> {
|
||||
self.base.base.telemetry_endpoints(chain_spec)
|
||||
}
|
||||
fn telemetry_endpoints(
|
||||
&self,
|
||||
chain_spec: &Box<dyn ChainSpec>,
|
||||
) -> Result<Option<sc_telemetry::TelemetryEndpoints>> {
|
||||
self.base.base.telemetry_endpoints(chain_spec)
|
||||
}
|
||||
|
||||
fn node_name(&self) -> Result<String> {
|
||||
self.base.base.node_name()
|
||||
}
|
||||
fn node_name(&self) -> Result<String> {
|
||||
self.base.base.node_name()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user