From ab888162b6b729f24d77ceae2422b6487f847b7f Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Oct 2026 13:35:39 +0100 Subject: genesis conflicts seeds or recover-from genesis together with seeds or recover-from is now an error wherever the values come from, and not settled by precedence. --- src/config/mod.rs | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'src/config/mod.rs') 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 + '_ { -- cgit v1.3.1