mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 19:47:59 +00:00
Make network_config_path an Option (#5661)
* Make network_config_path an Option * Fix network tests * Use None as the network config path * Fix cli * Don't make PathBuf an Option in a cli context
This commit is contained in:
@@ -173,7 +173,7 @@ macro_rules! substrate_cli_subcommands {
|
||||
&self,
|
||||
chain_spec: &::std::boxed::Box<dyn ::sc_service::ChainSpec>,
|
||||
is_dev: bool,
|
||||
net_config_dir: &::std::path::PathBuf,
|
||||
net_config_dir: ::std::path::PathBuf,
|
||||
client_id: &str,
|
||||
node_name: &str,
|
||||
node_key: ::sc_service::config::NodeKeyConfig,
|
||||
|
||||
@@ -110,7 +110,7 @@ pub trait CliConfiguration: Sized {
|
||||
&self,
|
||||
chain_spec: &Box<dyn ChainSpec>,
|
||||
is_dev: bool,
|
||||
net_config_dir: &PathBuf,
|
||||
net_config_dir: PathBuf,
|
||||
client_id: &str,
|
||||
node_name: &str,
|
||||
node_key: NodeKeyConfig,
|
||||
@@ -119,7 +119,7 @@ pub trait CliConfiguration: Sized {
|
||||
network_params.network_config(
|
||||
chain_spec,
|
||||
is_dev,
|
||||
net_config_dir,
|
||||
Some(net_config_dir),
|
||||
client_id,
|
||||
node_name,
|
||||
node_key,
|
||||
@@ -129,7 +129,7 @@ pub trait CliConfiguration: Sized {
|
||||
node_name,
|
||||
client_id,
|
||||
node_key,
|
||||
net_config_dir,
|
||||
Some(net_config_dir),
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -405,7 +405,7 @@ pub trait CliConfiguration: Sized {
|
||||
network: self.network_config(
|
||||
&chain_spec,
|
||||
is_dev,
|
||||
&net_config_dir,
|
||||
net_config_dir,
|
||||
client_id.as_str(),
|
||||
self.node_name()?.as_str(),
|
||||
node_key,
|
||||
|
||||
@@ -96,7 +96,7 @@ impl NetworkParams {
|
||||
&self,
|
||||
chain_spec: &Box<dyn ChainSpec>,
|
||||
is_dev: bool,
|
||||
net_config_path: &PathBuf,
|
||||
net_config_path: Option<PathBuf>,
|
||||
client_id: &str,
|
||||
node_name: &str,
|
||||
node_key: NodeKeyConfig,
|
||||
@@ -121,7 +121,7 @@ impl NetworkParams {
|
||||
|
||||
NetworkConfiguration {
|
||||
boot_nodes,
|
||||
net_config_path: net_config_path.clone(),
|
||||
net_config_path,
|
||||
reserved_nodes: self.reserved_nodes.clone(),
|
||||
non_reserved_mode: if self.reserved_only {
|
||||
NonReservedPeerMode::Deny
|
||||
|
||||
@@ -315,7 +315,7 @@ impl From<multiaddr::Error> for ParseErr {
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct NetworkConfiguration {
|
||||
/// Directory path to store network-specific configuration. None means nothing will be saved.
|
||||
pub net_config_path: PathBuf,
|
||||
pub net_config_path: Option<PathBuf>,
|
||||
/// Multiaddresses to listen for incoming connections.
|
||||
pub listen_addresses: Vec<Multiaddr>,
|
||||
/// Multiaddresses to advertise. Detected automatically if empty.
|
||||
@@ -351,10 +351,10 @@ impl NetworkConfiguration {
|
||||
node_name: SN,
|
||||
client_version: SV,
|
||||
node_key: NodeKeyConfig,
|
||||
net_config_path: &PathBuf,
|
||||
net_config_path: Option<PathBuf>,
|
||||
) -> Self {
|
||||
NetworkConfiguration {
|
||||
net_config_path: net_config_path.clone(),
|
||||
net_config_path,
|
||||
listen_addresses: Vec::new(),
|
||||
public_addresses: Vec::new(),
|
||||
boot_nodes: Vec::new(),
|
||||
@@ -384,7 +384,7 @@ impl NetworkConfiguration {
|
||||
"test-node",
|
||||
"test-client",
|
||||
Default::default(),
|
||||
&std::env::current_dir().expect("current directory must exist"),
|
||||
None,
|
||||
);
|
||||
|
||||
config.listen_addresses = vec![
|
||||
@@ -402,7 +402,7 @@ impl NetworkConfiguration {
|
||||
"test-node",
|
||||
"test-client",
|
||||
Default::default(),
|
||||
&std::env::current_dir().expect("current directory must exist"),
|
||||
None,
|
||||
);
|
||||
|
||||
config.listen_addresses = vec![
|
||||
|
||||
@@ -184,7 +184,9 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkWorker<B, H> {
|
||||
pub fn new(params: Params<B, H>) -> Result<NetworkWorker<B, H>, Error> {
|
||||
let (to_worker, from_worker) = tracing_unbounded("mpsc_network_worker");
|
||||
|
||||
fs::create_dir_all(¶ms.network_config.net_config_path)?;
|
||||
if let Some(path) = params.network_config.net_config_path {
|
||||
fs::create_dir_all(&path)?;
|
||||
}
|
||||
|
||||
// List of multiaddresses that we know in the network.
|
||||
let mut known_addresses = Vec::new();
|
||||
|
||||
@@ -607,7 +607,7 @@ pub trait TestNetFactory: Sized {
|
||||
"test-node",
|
||||
"test-client",
|
||||
Default::default(),
|
||||
&std::env::current_dir().expect("current directory must exist"),
|
||||
None,
|
||||
);
|
||||
network_config.transport = TransportConfig::MemoryOnly;
|
||||
network_config.listen_addresses = vec![listen_addr.clone()];
|
||||
@@ -683,7 +683,7 @@ pub trait TestNetFactory: Sized {
|
||||
"test-node",
|
||||
"test-client",
|
||||
Default::default(),
|
||||
&std::env::current_dir().expect("current directory must exist"),
|
||||
None,
|
||||
);
|
||||
network_config.transport = TransportConfig::MemoryOnly;
|
||||
network_config.listen_addresses = vec![listen_addr.clone()];
|
||||
|
||||
@@ -143,12 +143,11 @@ fn node_config<G: RuntimeGenesis + 'static, E: ChainSpecExtension + Clone + 'sta
|
||||
{
|
||||
let root = root.path().join(format!("node-{}", index));
|
||||
|
||||
let net_config_path = root.join("network");
|
||||
|
||||
let mut network_config = NetworkConfiguration::new(
|
||||
format!("Node {}", index),
|
||||
"network/test/0.1",
|
||||
Default::default(), &net_config_path,
|
||||
Default::default(),
|
||||
None,
|
||||
);
|
||||
|
||||
network_config.listen_addresses.push(
|
||||
|
||||
@@ -49,7 +49,7 @@ where
|
||||
format!("{} (Browser)", name),
|
||||
"unknown",
|
||||
Default::default(),
|
||||
&std::path::PathBuf::new(),
|
||||
None,
|
||||
);
|
||||
network.boot_nodes = chain_spec.boot_nodes().to_vec();
|
||||
network.transport = TransportConfig::Normal {
|
||||
|
||||
Reference in New Issue
Block a user