Skip to content

Commit

Permalink
feat: automated node config path args
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Mirko-von-Leipzig committed Jul 2, 2021
1 parent f68db59 commit 53d3aab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 26 additions & 2 deletions src/setup/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 53d3aab

Please sign in to comment.