Keep sets of initial peers as Strings in config file
This commit is contained in:
parent
b5bbef5c47
commit
0ac1b663fe
|
|
@ -1,5 +1,6 @@
|
||||||
use std::{
|
use std::{
|
||||||
net::{SocketAddr, ToSocketAddrs},
|
net::{SocketAddr, ToSocketAddrs},
|
||||||
|
string::String,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -22,11 +23,11 @@ pub struct Config {
|
||||||
/// mainnet.
|
/// mainnet.
|
||||||
///
|
///
|
||||||
/// XXX this should be replaced with DNS names, not SocketAddrs
|
/// XXX this should be replaced with DNS names, not SocketAddrs
|
||||||
pub initial_mainnet_peers: Vec<SocketAddr>,
|
pub initial_mainnet_peers: Vec<String>,
|
||||||
|
|
||||||
/// A list of initial peers for the peerset when operating on
|
/// A list of initial peers for the peerset when operating on
|
||||||
/// testnet.
|
/// testnet.
|
||||||
pub initial_testnet_peers: Vec<SocketAddr>,
|
pub initial_testnet_peers: Vec<String>,
|
||||||
|
|
||||||
/// The outgoing request buffer size for the peer set.
|
/// The outgoing request buffer size for the peer set.
|
||||||
pub peerset_request_buffer_size: usize,
|
pub peerset_request_buffer_size: usize,
|
||||||
|
|
@ -58,26 +59,36 @@ impl Config {
|
||||||
/// Get the initial seed peers based on the configured network.
|
/// Get the initial seed peers based on the configured network.
|
||||||
pub fn initial_peers(&self) -> Vec<SocketAddr> {
|
pub fn initial_peers(&self) -> Vec<SocketAddr> {
|
||||||
match self.network {
|
match self.network {
|
||||||
Network::Mainnet => self.initial_mainnet_peers.clone(),
|
Network::Mainnet => Config::parse_peers(self.initial_mainnet_peers.clone()),
|
||||||
Network::Testnet => self.initial_testnet_peers.clone(),
|
Network::Testnet => Config::parse_peers(self.initial_testnet_peers.clone()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
fn default() -> Config {
|
fn default() -> Config {
|
||||||
|
let mainnet_peers = [
|
||||||
|
"dnsseed.z.cash:8233",
|
||||||
|
"dnsseed.str4d.xyz:8233",
|
||||||
|
"dnsseed.znodes.org:8233",
|
||||||
|
]
|
||||||
|
.iter()
|
||||||
|
.map(|&s| String::from(s))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let testnet_peers = ["dnsseed.testnet.z.cash:18233"]
|
||||||
|
.iter()
|
||||||
|
.map(|&s| String::from(s))
|
||||||
|
.collect();
|
||||||
|
|
||||||
Config {
|
Config {
|
||||||
listen_addr: "127.0.0.1:28233"
|
listen_addr: "127.0.0.1:28233"
|
||||||
.parse()
|
.parse()
|
||||||
.expect("Hardcoded address should be parseable"),
|
.expect("Hardcoded address should be parseable"),
|
||||||
user_agent: crate::constants::USER_AGENT.to_owned(),
|
user_agent: crate::constants::USER_AGENT.to_owned(),
|
||||||
network: Network::Mainnet,
|
network: Network::Mainnet,
|
||||||
initial_mainnet_peers: Config::parse_peers(vec![
|
initial_mainnet_peers: mainnet_peers,
|
||||||
"dnsseed.z.cash:8233",
|
initial_testnet_peers: testnet_peers,
|
||||||
"dnsseed.str4d.xyz:8233",
|
|
||||||
"dnsseed.znodes.org:8233",
|
|
||||||
]),
|
|
||||||
initial_testnet_peers: Config::parse_peers(vec!["dnsseed.testnet.z.cash:18233"]),
|
|
||||||
ewma_default_rtt: Duration::from_secs(1),
|
ewma_default_rtt: Duration::from_secs(1),
|
||||||
ewma_decay_time: Duration::from_secs(60),
|
ewma_decay_time: Duration::from_secs(60),
|
||||||
peerset_request_buffer_size: 1,
|
peerset_request_buffer_size: 1,
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
//!
|
//!
|
||||||
//! See the `impl Configurable` below for how to specify the path to the
|
//! See the `impl Configurable` below for how to specify the path to the
|
||||||
//! application's configuration file.
|
//! application's configuration file.
|
||||||
|
// TODO: update the list of commands above or find a way to keep it
|
||||||
|
// automatically up to date.
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
mod connect;
|
mod connect;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ impl Runnable for ConfigCmd {
|
||||||
# can be found in Rustdoc. XXX add link to rendered docs.
|
# can be found in Rustdoc. XXX add link to rendered docs.
|
||||||
|
|
||||||
"
|
"
|
||||||
.to_owned();
|
.to_owned(); // The default name and location of the config file is defined in ../commands.rs
|
||||||
output += &toml::to_string_pretty(&default_config)
|
output += &toml::to_string_pretty(&default_config)
|
||||||
.expect("default config should be serializable");
|
.expect("default config should be serializable");
|
||||||
match self.output_file {
|
match self.output_file {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue