mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 18:27:56 +00:00
committed by
Bastian Köcher
parent
e8a655bbef
commit
0b52f194f5
@@ -14,10 +14,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pub use substrate_cli::error;
|
||||
pub use substrate_cli::VersionInfo;
|
||||
use tokio::prelude::Future;
|
||||
use tokio::runtime::{Builder as RuntimeBuilder, Runtime};
|
||||
pub use substrate_cli::{VersionInfo, IntoExit, NoCustom, SharedParams, ExecutionStrategyParam};
|
||||
use substrate_cli::{IntoExit, NoCustom, SharedParams, ImportParams, error};
|
||||
use substrate_service::{AbstractService, Roles as ServiceRoles, Configuration};
|
||||
use log::info;
|
||||
use structopt::{StructOpt, clap::App};
|
||||
@@ -25,7 +25,6 @@ use substrate_cli::{display_role, parse_and_prepare, AugmentClap, GetLogFilter,
|
||||
use crate::{service, ChainSpec, load_spec};
|
||||
use crate::factory_impl::FactoryState;
|
||||
use transaction_factory::RuntimeAdapter;
|
||||
use client::ExecutionStrategies;
|
||||
|
||||
/// Custom subcommands.
|
||||
#[derive(Clone, Debug, StructOpt)]
|
||||
@@ -82,15 +81,9 @@ pub struct FactoryCmd {
|
||||
#[structopt(flatten)]
|
||||
pub shared_params: SharedParams,
|
||||
|
||||
/// The means of execution used when calling into the runtime while importing blocks.
|
||||
#[structopt(
|
||||
long = "execution",
|
||||
value_name = "STRATEGY",
|
||||
possible_values = &ExecutionStrategyParam::variants(),
|
||||
case_insensitive = true,
|
||||
default_value = "NativeElseWasm"
|
||||
)]
|
||||
pub execution: ExecutionStrategyParam,
|
||||
#[allow(missing_docs)]
|
||||
#[structopt(flatten)]
|
||||
pub import_params: ImportParams,
|
||||
}
|
||||
|
||||
impl AugmentClap for FactoryCmd {
|
||||
@@ -147,12 +140,8 @@ pub fn run<I, T, E>(args: I, exit: E, version: substrate_cli::VersionInfo) -> er
|
||||
&cli_args.shared_params,
|
||||
&version,
|
||||
)?;
|
||||
config.execution_strategies = ExecutionStrategies {
|
||||
importing: cli_args.execution.into(),
|
||||
block_construction: cli_args.execution.into(),
|
||||
other: cli_args.execution.into(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
substrate_cli::fill_import_params(&mut config, &cli_args.import_params, ServiceRoles::FULL)?;
|
||||
|
||||
match ChainSpec::from(config.chain_spec.id()) {
|
||||
Some(ref c) if c == &ChainSpec::Development || c == &ChainSpec::LocalTestnet => {},
|
||||
|
||||
@@ -56,7 +56,7 @@ use params::{
|
||||
NetworkConfigurationParams, MergeParameters, TransactionPoolParams,
|
||||
NodeKeyParams, NodeKeyType, Cors, CheckBlockCmd,
|
||||
};
|
||||
pub use params::{NoCustom, CoreParams, SharedParams, ExecutionStrategy as ExecutionStrategyParam};
|
||||
pub use params::{NoCustom, CoreParams, SharedParams, ImportParams, ExecutionStrategy};
|
||||
pub use traits::{GetLogFilter, AugmentClap};
|
||||
use app_dirs::{AppInfo, AppDataType};
|
||||
use log::info;
|
||||
@@ -440,7 +440,8 @@ impl<'a> ParseAndPrepareImport<'a> {
|
||||
E: ChainSpecExtension,
|
||||
Exit: IntoExit
|
||||
{
|
||||
let config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?;
|
||||
let mut config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?;
|
||||
fill_import_params(&mut config, &self.params.import_params, service::Roles::FULL)?;
|
||||
|
||||
let file: Box<dyn ReadPlusSeek + Send> = match self.params.input {
|
||||
Some(filename) => Box::new(File::open(filename)?),
|
||||
@@ -499,7 +500,8 @@ impl<'a> CheckBlock<'a> {
|
||||
E: ChainSpecExtension,
|
||||
Exit: IntoExit
|
||||
{
|
||||
let config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?;
|
||||
let mut config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?;
|
||||
fill_import_params(&mut config, &self.params.import_params, service::Roles::FULL)?;
|
||||
|
||||
let input = if self.params.input.starts_with("0x") { &self.params.input[2..] } else { &self.params.input[..] };
|
||||
let block_id = match FromStr::from_str(input) {
|
||||
@@ -738,7 +740,8 @@ fn fill_config_keystore_password<C, G, E>(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn fill_shared_config<C, G, E>(config: &mut Configuration<C, G, E>, cli: &SharedParams, role: service::Roles)
|
||||
/// Put block import CLI params into `config` object.
|
||||
pub fn fill_import_params<C, G, E>(config: &mut Configuration<C, G, E>, cli: &ImportParams, role: service::Roles)
|
||||
-> error::Result<()>
|
||||
where
|
||||
C: Default,
|
||||
@@ -776,7 +779,7 @@ where
|
||||
config.wasm_method = cli.wasm_method.into();
|
||||
|
||||
let exec = &cli.execution_strategies;
|
||||
let exec_all_or = |strat: params::ExecutionStrategy| exec.execution.unwrap_or(strat).into();
|
||||
let exec_all_or = |strat: ExecutionStrategy| exec.execution.unwrap_or(strat).into();
|
||||
config.execution_strategies = ExecutionStrategies {
|
||||
syncing: exec_all_or(exec.execution_syncing),
|
||||
importing: exec_all_or(exec.execution_import_block),
|
||||
@@ -813,7 +816,7 @@ where
|
||||
service::Roles::FULL
|
||||
};
|
||||
|
||||
fill_shared_config(&mut config, &cli.shared_params, role)?;
|
||||
fill_import_params(&mut config, &cli.import_params, role)?;
|
||||
|
||||
config.impl_name = impl_name;
|
||||
config.impl_commit = version.commit;
|
||||
@@ -924,8 +927,7 @@ where
|
||||
let spec = load_spec(cli, spec_factory)?;
|
||||
let base_path = base_path(cli, version);
|
||||
|
||||
let mut config = service::Configuration::default_with_spec_and_base_path(spec.clone(), Some(base_path));
|
||||
fill_shared_config(&mut config, &cli, service::Roles::FULL)?;
|
||||
let config = service::Configuration::default_with_spec_and_base_path(spec.clone(), Some(base_path));
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,11 @@ pub struct SharedParams {
|
||||
/// Sets a custom logging filter.
|
||||
#[structopt(short = "l", long = "log", value_name = "LOG_PATTERN")]
|
||||
pub log: Option<String>,
|
||||
}
|
||||
|
||||
/// Parameters for block import.
|
||||
#[derive(Debug, StructOpt, Clone)]
|
||||
pub struct ImportParams {
|
||||
/// Specify the state pruning mode, a number of blocks to keep or 'archive'.
|
||||
///
|
||||
/// Default is to keep all block states if the node is running as a
|
||||
@@ -505,6 +509,10 @@ pub struct RunCmd {
|
||||
#[structopt(flatten)]
|
||||
pub shared_params: SharedParams,
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[structopt(flatten)]
|
||||
pub import_params: ImportParams,
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[structopt(flatten)]
|
||||
pub network_config: NetworkConfigurationParams,
|
||||
@@ -764,6 +772,10 @@ pub struct ImportBlocksCmd {
|
||||
#[allow(missing_docs)]
|
||||
#[structopt(flatten)]
|
||||
pub shared_params: SharedParams,
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[structopt(flatten)]
|
||||
pub import_params: ImportParams,
|
||||
}
|
||||
|
||||
impl_get_log_filter!(ImportBlocksCmd);
|
||||
@@ -784,6 +796,10 @@ pub struct CheckBlockCmd {
|
||||
#[allow(missing_docs)]
|
||||
#[structopt(flatten)]
|
||||
pub shared_params: SharedParams,
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[structopt(flatten)]
|
||||
pub import_params: ImportParams,
|
||||
}
|
||||
|
||||
impl_get_log_filter!(CheckBlockCmd);
|
||||
|
||||
Reference in New Issue
Block a user