mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-21 18:40:39 +08:00
node: Update Config Default instance
Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
+12
-1
@@ -141,7 +141,7 @@ pub enum RemoteTracking {
|
||||
}
|
||||
|
||||
/// Protocol configuration.
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Config {
|
||||
/// Peers to connect to on startup.
|
||||
/// Connections to these peers will be maintained.
|
||||
@@ -154,6 +154,17 @@ pub struct Config {
|
||||
pub relay: bool,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
connect: Vec::default(),
|
||||
project_tracking: ProjectTracking::default(),
|
||||
remote_tracking: RemoteTracking::default(),
|
||||
relay: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn is_persistent(&self, addr: &net::SocketAddr) -> bool {
|
||||
self.connect.contains(addr)
|
||||
|
||||
+2
-22
@@ -103,17 +103,7 @@ fn test_wrong_peer_magic() {
|
||||
|
||||
#[test]
|
||||
fn test_inventory_relay_bad_seq() {
|
||||
let mut alice = Peer::config(
|
||||
"alice",
|
||||
Config {
|
||||
relay: true,
|
||||
..Config::default()
|
||||
},
|
||||
[7, 7, 7, 7],
|
||||
vec![],
|
||||
MockStorage::empty(),
|
||||
fastrand::Rng::new(),
|
||||
);
|
||||
let mut alice = Peer::new("alice", [7, 7, 7, 7], MockStorage::empty());
|
||||
let bob = Peer::new("bob", [8, 8, 8, 8], MockStorage::empty());
|
||||
|
||||
alice.connect_to(&bob.addr());
|
||||
@@ -135,17 +125,7 @@ fn test_inventory_relay_bad_seq() {
|
||||
#[test]
|
||||
fn test_inventory_relay() {
|
||||
// Topology is eve <-> alice <-> bob
|
||||
let mut alice = Peer::config(
|
||||
"alice",
|
||||
Config {
|
||||
relay: true,
|
||||
..Config::default()
|
||||
},
|
||||
[7, 7, 7, 7],
|
||||
vec![],
|
||||
MockStorage::empty(),
|
||||
fastrand::Rng::new(),
|
||||
);
|
||||
let mut alice = Peer::new("alice", [7, 7, 7, 7], MockStorage::empty());
|
||||
let bob = Peer::new("bob", [8, 8, 8, 8], MockStorage::empty());
|
||||
let eve = Peer::new("eve", [9, 9, 9, 9], MockStorage::empty());
|
||||
let inv = vec![];
|
||||
|
||||
Reference in New Issue
Block a user