mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 23:57:56 +00:00
Add a feature to create automatically a random temporary directory for base path & remove Clone (#6221)
* Initial commit Forked at:4adac40c07Parent branch: origin/master * Add a feature to create automatically a temporary directory for base path * doc fix and todos * use parking_lot instead * use refcell instead since we stay in the main thread * remove Clone derives * add test * solving dependency issue * clarifying doc * conflict argument with base-path * WIP Forked at:4adac40c07Parent branch: origin/master * revert dep deletion * fixing test and making base_path optional * hold basepath while the service is running * fixes * Update client/cli/src/params/shared_params.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/Cargo.toml Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/cli/src/commands/mod.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/config.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * WIP Forked at:4adac40c07Parent branch: origin/master * improve doc Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -27,9 +27,9 @@ use crate::{
|
||||
use names::{Generator, Name};
|
||||
use sc_client_api::execution_extensions::ExecutionStrategies;
|
||||
use sc_service::config::{
|
||||
Configuration, DatabaseConfig, ExtTransport, KeystoreConfig, NetworkConfiguration,
|
||||
NodeKeyConfig, OffchainWorkerConfig, PrometheusConfig, PruningMode, Role, RpcMethods,
|
||||
TaskType, TelemetryEndpoints, TransactionPoolOptions, WasmExecutionMethod,
|
||||
BasePath, Configuration, DatabaseConfig, ExtTransport, KeystoreConfig, NetworkConfiguration,
|
||||
NodeKeyConfig, OffchainWorkerConfig, PrometheusConfig, PruningMode, Role, RpcMethods, TaskType,
|
||||
TelemetryEndpoints, TransactionPoolOptions, WasmExecutionMethod,
|
||||
};
|
||||
use sc_service::{ChainSpec, TracingReceiver};
|
||||
use std::future::Future;
|
||||
@@ -87,7 +87,7 @@ pub trait CliConfiguration: Sized {
|
||||
/// Get the base path of the configuration (if any)
|
||||
///
|
||||
/// By default this is retrieved from `SharedParams`.
|
||||
fn base_path(&self) -> Result<Option<PathBuf>> {
|
||||
fn base_path(&self) -> Result<Option<BasePath>> {
|
||||
Ok(self.shared_params().base_path())
|
||||
}
|
||||
|
||||
@@ -402,14 +402,12 @@ pub trait CliConfiguration: Sized {
|
||||
let is_dev = self.is_dev()?;
|
||||
let chain_id = self.chain_id(is_dev)?;
|
||||
let chain_spec = cli.load_spec(chain_id.as_str())?;
|
||||
let config_dir = self
|
||||
let base_path = self
|
||||
.base_path()?
|
||||
.unwrap_or_else(|| {
|
||||
directories::ProjectDirs::from("", "", C::executable_name())
|
||||
.expect("app directories exist on all supported platforms; qed")
|
||||
.data_local_dir()
|
||||
.into()
|
||||
})
|
||||
.unwrap_or_else(|| BasePath::from_project("", "", C::executable_name()));
|
||||
let config_dir = base_path
|
||||
.path()
|
||||
.to_path_buf()
|
||||
.join("chains")
|
||||
.join(chain_spec.id());
|
||||
let net_config_dir = config_dir.join(DEFAULT_NETWORK_CONFIG_PATH);
|
||||
@@ -464,6 +462,7 @@ pub trait CliConfiguration: Sized {
|
||||
max_runtime_instances,
|
||||
announce_block: self.announce_block()?,
|
||||
role,
|
||||
base_path: Some(base_path),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -507,5 +506,5 @@ pub fn generate_node_name() -> String {
|
||||
if count < NODE_NAME_MAX_LENGTH {
|
||||
return node_name;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user