From f091fb2a9188f686e5b1f9012c510a1b3c8ad840 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Oct 2026 16:32:23 +0100 Subject: move transport config checks to respective modules --- src/transport/mod.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/transport/mod.rs') diff --git a/src/transport/mod.rs b/src/transport/mod.rs index d8c6e2b..fd3651b 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -34,6 +34,27 @@ compile_error!( "continuum needs a transport: build with at least one of the mycelium, libp2p and tor features, e.g. `cargo build --features mycelium`" ); +/// The options of the transports this build has, each checked by its transport when the +/// configuration is loaded (`config::Settings::check`, after the names in `transports`): +/// Mycelium's always (its conflicts are errors wherever they come from, as before); +/// libp2p's and Tor's if the node uses them. Options of transports not built aren't +/// checked: they're ignored, and said so (`config::Loaded::unused_transport_options`). +pub(crate) fn check(settings: &crate::config::Settings) -> Result<()> { + let uses = |name: &str| settings.transports.iter().any(|used| used == name); + let _ = uses; + #[cfg(feature = "mycelium")] + mycelium::check(settings)?; + #[cfg(feature = "libp2p")] + if uses("libp2p") { + libp2p::check(settings)?; + } + #[cfg(feature = "tor")] + if uses("tor") { + tor::TorTransport::check(settings)?; + } + Ok(()) +} + /// Starts the transport `name` (one of `config::TRANSPORTS`) as `settings` configure /// it: its scheme and the transport, or None if `stop` came first (some take a while to /// start: a supervised Mycelium daemon, arti). `key`: the node key, which some prove -- cgit v1.3.1