diff --git a/Cargo.lock b/Cargo.lock index 7fee428e..007941db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3217,6 +3217,7 @@ dependencies = [ "cyphernet", "fastrand", "gix-packetline", + "indexmap", "lexopt", "log", "mio", diff --git a/Cargo.toml b/Cargo.toml index 2672ff30..b1c37ea7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,6 +34,7 @@ gix-hash = { version = "0.22.1", default-features = false, features = ["sha1"] } gix-packetline = { version = "0.21.1", default-features = false } human-panic = "2.0.6" humantime = "2.3" +indexmap = { version = "2", default-features = false } itertools = "0.14" lexopt = "0.3.0" libc = "0.2.137" diff --git a/crates/radicle-node/Cargo.toml b/crates/radicle-node/Cargo.toml index 3da0f15a..17b0b164 100644 --- a/crates/radicle-node/Cargo.toml +++ b/crates/radicle-node/Cargo.toml @@ -23,6 +23,7 @@ crossbeam-channel = { workspace = true } cyphernet = { workspace = true, features = ["dns", "ed25519", "p2p-ed25519", "noise-framework", "noise_sha2"] } fastrand = { workspace = true } gix-packetline = { workspace = true, features = ["blocking-io"] } +indexmap = { workspace = true } lexopt = { workspace = true } log = { workspace = true, features = ["kv", "std"] } mio = { version = "1", features = ["net", "os-poll"] } diff --git a/crates/radicle-node/src/tests.rs b/crates/radicle-node/src/tests.rs index 789ad4fd..dd19425f 100644 --- a/crates/radicle-node/src/tests.rs +++ b/crates/radicle-node/src/tests.rs @@ -233,11 +233,11 @@ fn test_inbound_connection() { #[test] fn test_persistent_peer_connect() { - use std::collections::HashSet; + use indexmap::IndexSet; let bob = Peer::new("bob", [8, 8, 8, 8]); let eve = Peer::new("eve", [9, 9, 9, 9]); - let connect = HashSet::::from_iter([ + let connect = IndexSet::::from_iter([ (bob.id(), bob.address()).into(), (eve.id(), eve.address()).into(), ]); @@ -1186,7 +1186,7 @@ fn test_inventory_relay() { #[test] fn test_persistent_peer_reconnect_attempt() { - use std::collections::HashSet; + use indexmap::IndexSet; let mut bob = Peer::new("bob", [8, 8, 8, 8]); let mut eve = Peer::new("eve", [9, 9, 9, 9]); @@ -1196,7 +1196,7 @@ fn test_persistent_peer_reconnect_attempt() { MockStorage::empty(), peer::Config { config: Config { - connect: HashSet::from_iter([ + connect: IndexSet::from_iter([ (bob.id(), bob.address()).into(), (eve.id(), eve.address()).into(), ]), @@ -1246,7 +1246,7 @@ fn test_persistent_peer_reconnect_attempt() { #[test] fn test_persistent_peer_reconnect_success() { - use std::collections::HashSet; + use indexmap::IndexSet; let bob = Peer::with_storage("bob", [9, 9, 9, 9], MockStorage::empty()); let mut alice = Peer::config( @@ -1255,7 +1255,7 @@ fn test_persistent_peer_reconnect_success() { MockStorage::empty(), peer::Config { config: Config { - connect: HashSet::from_iter([(bob.id, bob.addr()).into()]), + connect: IndexSet::from_iter([(bob.id, bob.addr()).into()]), ..Config::new(node::Alias::new("alice")) }, ..peer::Config::default() diff --git a/crates/radicle/Cargo.toml b/crates/radicle/Cargo.toml index d5ee2d54..b94839de 100644 --- a/crates/radicle/Cargo.toml +++ b/crates/radicle/Cargo.toml @@ -42,7 +42,7 @@ dunce = { workspace = true } fast-glob = { version = "0.3.2" } fastrand = { workspace = true, features = ["std"] } git2 = { workspace = true, features = ["vendored-libgit2"] } -indexmap = { version = "2", features = ["serde"] } +indexmap = { workspace = true, features = ["serde"] } log = { workspace = true, features = ["std"] } nonempty = { workspace = true, features = ["serialize"] } qcheck = { workspace = true, optional = true } diff --git a/crates/radicle/src/node/config.rs b/crates/radicle/src/node/config.rs index 1cb6492b..34422c5b 100644 --- a/crates/radicle/src/node/config.rs +++ b/crates/radicle/src/node/config.rs @@ -1,9 +1,9 @@ -use std::collections::HashSet; use std::ops::Deref; use std::str::FromStr; use std::{fmt, net}; use cyphernet::addr::PeerAddr; +use indexmap::IndexSet; use localtime::LocalDuration; use serde::{Deserialize, Serialize}; use serde_json as json; @@ -547,7 +547,11 @@ pub struct Config { /// Peers to connect to on startup. /// Connections to these peers will be maintained. #[serde(default)] - pub connect: HashSet, + #[cfg_attr( + feature = "schemars", + schemars(with = "std::collections::HashSet") + )] + pub connect: IndexSet, /// Specify the node's public addresses #[serde(default)] pub external_addresses: Vec
, @@ -617,7 +621,7 @@ impl Config { user_agent: Some(UserAgent::default()), peers: PeerConfig::default(), listen: vec![], - connect: HashSet::default(), + connect: IndexSet::default(), external_addresses: vec![], network: Network::default(), proxy: None,