aboutsummaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/config')
-rw-r--r--src/config/mod.rs34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 99690ae..0c57713 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -260,8 +260,12 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[
"transports",
Kind::List,
"NAME,[NAME...]",
- Some("mycelium"),
- "The transports this node uses, in order of preference: mycelium, libp2p and tor (in builds with the libp2p and tor features). A peer is reached on the first one both have, until the paths are measured (then on the fastest); nodes on several carry the traffic between nodes that share none.",
+ if cfg!(feature = "mycelium") {
+ Some("mycelium")
+ } else {
+ None
+ },
+ "The transports this node uses, in order of preference: mycelium, libp2p and tor (each in builds with its cargo feature; mycelium is the default where built). A peer is reached on the first one both have, until the paths are measured (then on the fastest); nodes on several carry the traffic between nodes that share none.",
),
option(
"libp2p-listen",
@@ -501,12 +505,18 @@ pub(crate) struct Settings {
pub(crate) tor_port: u16,
#[serde(default)]
pub(crate) relay_only: bool,
+ #[cfg_attr(not(feature = "mycelium"), allow(dead_code))]
pub(crate) mycelium_rest_url: Option<String>,
+ #[cfg_attr(not(feature = "mycelium"), allow(dead_code))]
pub(crate) mycelium_key_file: Option<PathBuf>,
+ #[cfg_attr(not(feature = "mycelium"), allow(dead_code))]
pub(crate) mycelium_network_key_file: Option<PathBuf>,
+ #[cfg_attr(not(feature = "mycelium"), allow(dead_code))]
pub(crate) mycelium_network_name: Option<String>,
+ #[cfg_attr(not(feature = "mycelium"), allow(dead_code))]
pub(crate) mycelium_tcp_listen_port: Option<u16>,
#[serde(default = "default_mycelium_peers")]
+ #[cfg_attr(not(feature = "mycelium"), allow(dead_code))]
pub(crate) mycelium_peers: Vec<String>,
pub(crate) debug_epoch: Option<u64>,
}
@@ -532,12 +542,17 @@ fn default_electorate_window() -> Duration {
fn default_blob_chunk() -> u64 {
64 * 1024
}
+/// Mycelium where built; else none, so the transports must be named.
fn default_transports() -> Vec<String> {
- vec!["mycelium".to_owned()]
+ if cfg!(feature = "mycelium") {
+ vec!["mycelium".to_owned()]
+ } else {
+ Vec::new()
+ }
}
/// The transports `transports` may name, and whether this build has each.
pub(crate) const TRANSPORTS: &[(&str, bool)] = &[
- ("mycelium", true),
+ ("mycelium", cfg!(feature = "mycelium")),
("libp2p", cfg!(feature = "libp2p")),
("tor", cfg!(feature = "tor")),
];
@@ -553,6 +568,7 @@ fn default_mycelium_peers() -> Vec<String> {
impl Settings {
/// `mycelium-rest-url`, parsed (checked when loading).
+ #[cfg_attr(not(feature = "mycelium"), allow(dead_code))]
pub(crate) fn mycelium_rest_url(&self) -> Option<url::Url> {
self.mycelium_rest_url
.as_deref()
@@ -628,7 +644,15 @@ impl Settings {
}
}
if self.transports.is_empty() {
- bail!("transports: a node needs at least one");
+ bail!(
+ "transports: a node needs at least one (this build has: {})",
+ TRANSPORTS
+ .iter()
+ .filter(|(_, built)| *built)
+ .map(|(name, _)| *name)
+ .collect::<Vec<_>>()
+ .join(", ")
+ );
}
if self.transports.iter().any(|name| name == "tor") && self.tor_state_dir.is_none() {
bail!(