mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-21 10:30:41 +08:00
47 lines
1.4 KiB
Rust
47 lines
1.4 KiB
Rust
use std::collections::HashMap;
|
|
use std::sync::LazyLock;
|
|
|
|
use radicle::node::config::ConnectAddress;
|
|
use radicle::node::Address;
|
|
use radicle::profile::Config;
|
|
|
|
static NODES_RENAMED: LazyLock<HashMap<Address, Address>> = LazyLock::new(|| {
|
|
HashMap::from([
|
|
(
|
|
"seed.radicle.garden:8776".parse().unwrap(),
|
|
"iris.radicle.xyz:8776".parse().unwrap(),
|
|
),
|
|
(
|
|
"ash.radicle.garden:8776".parse().unwrap(),
|
|
"rosa.radicle.xyz:8776".parse().unwrap(),
|
|
),
|
|
])
|
|
});
|
|
|
|
fn nodes_renamed_for_option(
|
|
option: &'static str,
|
|
iter: impl IntoIterator<Item = ConnectAddress>,
|
|
) -> Vec<String> {
|
|
let mut warnings: Vec<String> = vec![];
|
|
|
|
for (i, value) in iter.into_iter().enumerate() {
|
|
let old: Address = value.into();
|
|
if let Some(new) = NODES_RENAMED.get(&old) {
|
|
warnings.push(format!(
|
|
"Value of configuration option `{option}` at index {i} mentions node with address '{old}', which has been renamed to '{new}'. Please update your configuration."
|
|
));
|
|
}
|
|
}
|
|
|
|
warnings
|
|
}
|
|
|
|
pub(crate) fn nodes_renamed(config: &Config) -> Vec<String> {
|
|
let mut warnings = nodes_renamed_for_option("node.connect", config.node.connect.clone());
|
|
warnings.extend(nodes_renamed_for_option(
|
|
"preferred_seeds",
|
|
config.preferred_seeds.clone(),
|
|
));
|
|
warnings
|
|
}
|