node: Update `Config` `Default` instance
Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
parent
9b3f5b9f3c
commit
9873a36463
|
|
@ -141,7 +141,7 @@ pub enum RemoteTracking {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Protocol configuration.
|
/// Protocol configuration.
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
/// Peers to connect to on startup.
|
/// Peers to connect to on startup.
|
||||||
/// Connections to these peers will be maintained.
|
/// Connections to these peers will be maintained.
|
||||||
|
|
@ -154,6 +154,17 @@ pub struct Config {
|
||||||
pub relay: bool,
|
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 {
|
impl Config {
|
||||||
pub fn is_persistent(&self, addr: &net::SocketAddr) -> bool {
|
pub fn is_persistent(&self, addr: &net::SocketAddr) -> bool {
|
||||||
self.connect.contains(addr)
|
self.connect.contains(addr)
|
||||||
|
|
|
||||||
|
|
@ -103,17 +103,7 @@ fn test_wrong_peer_magic() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_inventory_relay_bad_seq() {
|
fn test_inventory_relay_bad_seq() {
|
||||||
let mut alice = Peer::config(
|
let mut alice = Peer::new("alice", [7, 7, 7, 7], MockStorage::empty());
|
||||||
"alice",
|
|
||||||
Config {
|
|
||||||
relay: true,
|
|
||||||
..Config::default()
|
|
||||||
},
|
|
||||||
[7, 7, 7, 7],
|
|
||||||
vec![],
|
|
||||||
MockStorage::empty(),
|
|
||||||
fastrand::Rng::new(),
|
|
||||||
);
|
|
||||||
let bob = Peer::new("bob", [8, 8, 8, 8], MockStorage::empty());
|
let bob = Peer::new("bob", [8, 8, 8, 8], MockStorage::empty());
|
||||||
|
|
||||||
alice.connect_to(&bob.addr());
|
alice.connect_to(&bob.addr());
|
||||||
|
|
@ -135,17 +125,7 @@ fn test_inventory_relay_bad_seq() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_inventory_relay() {
|
fn test_inventory_relay() {
|
||||||
// Topology is eve <-> alice <-> bob
|
// Topology is eve <-> alice <-> bob
|
||||||
let mut alice = Peer::config(
|
let mut alice = Peer::new("alice", [7, 7, 7, 7], MockStorage::empty());
|
||||||
"alice",
|
|
||||||
Config {
|
|
||||||
relay: true,
|
|
||||||
..Config::default()
|
|
||||||
},
|
|
||||||
[7, 7, 7, 7],
|
|
||||||
vec![],
|
|
||||||
MockStorage::empty(),
|
|
||||||
fastrand::Rng::new(),
|
|
||||||
);
|
|
||||||
let bob = Peer::new("bob", [8, 8, 8, 8], 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 eve = Peer::new("eve", [9, 9, 9, 9], MockStorage::empty());
|
||||||
let inv = vec![];
|
let inv = vec![];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue