summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/config/mod.rs35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 24791d3..0771e7e 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -107,7 +107,7 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[
Kind::Flag,
"BOOL",
Some("false"),
- "Start a new swarm, as its genesis node, instead of joining one through seeds. Every start with it starts another new swarm: drop it once the swarm exists, and give the node seeds instead. With a --state-file that remembers a swarm, it starts that swarm again instead (empty; nodes of it still running merge with this one).",
+ "Start a new swarm, as its genesis node, instead of joining one through seeds. Every start with it starts another new swarm: drop it once the swarm exists, and give the node seeds instead. Can't be combined with seeds. With a --state-file that remembers a swarm, it starts that swarm again instead (empty; nodes of it still running merge with this one).",
),
option(
"recover-from",
@@ -311,6 +311,15 @@ impl Settings {
);
}
}
+ // Contradictions, not overrides: an error wherever the options come from.
+ if self.genesis && !self.seeds.is_empty() {
+ bail!(
+ "genesis starts a new swarm, so there are no seeds to join through; unset seeds (--unset seeds) or genesis"
+ );
+ }
+ if self.genesis && self.recover_from.is_some() {
+ bail!("recover-from starts the swarm from a backup; it can't be combined with genesis");
+ }
if self.debug_epoch.is_some() && !self.debug_api {
bail!("debug-epoch needs debug-api");
}
@@ -425,21 +434,15 @@ fn unset_entry(provenance: Provenance) -> Entry {
/// values from earlier sources (lower precedence), so e.g. `--mycelium-rest-url` on the
/// command line overrides `mycelium-key-file` from a file. Both set in one source is an
/// error (`Settings::check`).
-const CONFLICTS: &[(&[&str], &[&str])] = &[
- (
- &["mycelium-rest-url"],
- &[
- "mycelium-key-file",
- "mycelium-network-key-file",
- "mycelium-network-name",
- "mycelium-tcp-listen-port",
- ],
- ),
- // A new swarm has nobody to join.
- (&["genesis"], &["seeds"]),
- // Recovering starts the swarm too.
- (&["recover-from"], &["genesis"]),
-];
+const CONFLICTS: &[(&[&str], &[&str])] = &[(
+ &["mycelium-rest-url"],
+ &[
+ "mycelium-key-file",
+ "mycelium-network-key-file",
+ "mycelium-network-name",
+ "mycelium-tcp-listen-port",
+ ],
+)];
/// The options `name` can't be combined with.
fn conflicting(name: &str) -> impl Iterator<Item = &'static str> + '_ {