From 53d3aab0372a200998d395e0e4aa9ec9e1b18637 Mon Sep 17 00:00:00 2001 From: Mirko von Leipzig Date: Fri, 2 Jul 2021 14:14:39 +0200 Subject: [PATCH] feat: automated node config path args The user previously had to specify the location of our generated config file. This change removes this requirement -- since we generate it, we should also pass on the information to the node. --- README.md | 4 ++-- src/setup/node.rs | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2d28a6c4..4cc94c89 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,11 @@ Ziggurat is configured with a `config.toml` file in the root. ```toml kind = "zebra" path = "path/to/zebra/repo" -start_command = "cargo +stable r -- --config zebra.toml --verbose start" +start_command = "cargo +stable r -- --verbose start" # kind = "zcashd" # path = "path/to/zcash/repo" -# start_command = "./src/zcashd -debug=1 -dnsseed=0 -printtoconsole -logips=1 -listenonion=0 -dns=0 -conf=/path/to/zcash/repo/zcash.conf" +# start_command = "./src/zcashd -debug=1 -dnsseed=0 -printtoconsole -logips=1 -listenonion=0 -dns=0" ``` Information about the node to be tested can be set under the `[node]` table: diff --git a/src/setup/node.rs b/src/setup/node.rs index 9242582f..43ad5ad1 100644 --- a/src/setup/node.rs +++ b/src/setup/node.rs @@ -67,11 +67,35 @@ impl Node { let config = NodeConfig::new(); let meta = NodeMetaData::new()?; - Ok(Self { + let mut node = Self { config, meta, process: None, - }) + }; + + // insert the config file cmd args + match node.meta.kind { + NodeKind::Zebra => { + // Bit more convoluted since we need to insert the args before `start`, which comes last. + let start_arg = node + .meta + .start_args + .pop() + .expect("Expected at least one arg for Zebra (`start`)"); + node.meta.start_args.push("--config".into()); + node.meta + .start_args + .push(node.config_filepath().into_os_string()); + node.meta.start_args.push(start_arg); + } + NodeKind::Zcashd => { + node.meta + .start_args + .push(format!("-conf={}", node.config_filepath().to_str().unwrap()).into()); + } + } + + Ok(node) } /// Returns the (external) address of the node.