Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: Update `Config` `Default` instance
Alexis Sellier committed 3 years ago
commit 9873a364638732d72e7e24df0c0a63ecd9c6adee
parent 9b3f5b9f3c9fd45a212fc53c041ccab371381290
2 files changed +14 -23
modified node/src/protocol.rs
@@ -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)
modified node/src/test/tests.rs
@@ -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![];