Remove rendezvous point default

This also fixes a bug where an empty string wasn't actually allowed
as a rendezvous point in the ASB's initial setup wizard.
This commit is contained in:
Thomas Eizinger 2021-07-09 09:44:37 +10:00
parent 3e3015a478
commit d21bd556ec
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96
3 changed files with 12 additions and 19 deletions

View File

@ -1,6 +1,5 @@
use crate::env::{Mainnet, Testnet}; use crate::env::{Mainnet, Testnet};
use crate::fs::{ensure_directory_exists, system_config_dir, system_data_dir}; use crate::fs::{ensure_directory_exists, system_config_dir, system_data_dir};
use crate::network::rendezvous::DEFAULT_RENDEZVOUS_ADDRESS;
use crate::tor::{DEFAULT_CONTROL_PORT, DEFAULT_SOCKS5_PORT}; use crate::tor::{DEFAULT_CONTROL_PORT, DEFAULT_SOCKS5_PORT};
use anyhow::{bail, Context, Result}; use anyhow::{bail, Context, Result};
use config::ConfigError; use config::ConfigError;
@ -249,7 +248,7 @@ pub fn query_user_for_initial_config(testnet: bool) -> Result<Config> {
.map(|str| str.parse()) .map(|str| str.parse())
.collect::<Result<Vec<Multiaddr>, _>>()?; .collect::<Result<Vec<Multiaddr>, _>>()?;
let electrum_rpc_url: Url = Input::with_theme(&ColorfulTheme::default()) let electrum_rpc_url = Input::with_theme(&ColorfulTheme::default())
.with_prompt("Enter Electrum RPC URL or hit return to use default") .with_prompt("Enter Electrum RPC URL or hit return to use default")
.default(defaults.electrum_rpc_url) .default(defaults.electrum_rpc_url)
.interact_text()?; .interact_text()?;
@ -290,24 +289,22 @@ pub fn query_user_for_initial_config(testnet: bool) -> Result<Config> {
} }
let ask_spread = Decimal::from_f64(ask_spread).context("Unable to parse spread")?; let ask_spread = Decimal::from_f64(ask_spread).context("Unable to parse spread")?;
let rendezvous_address = Input::with_theme(&ColorfulTheme::default()) let rendezvous_point = Input::<Multiaddr>::with_theme(&ColorfulTheme::default())
.with_prompt("Do you want to advertise your ASB instance with a rendezvous node? Enter an empty string if not.") .with_prompt("Do you want to advertise your ASB instance with a rendezvous node? Enter an empty string if not.")
.default(DEFAULT_RENDEZVOUS_ADDRESS.to_string()) .allow_empty(true)
.interact_text()?; .interact_text()?;
let rendezvous_point = if rendezvous_address.is_empty() {
None
} else {
Some(Multiaddr::from_str(&rendezvous_address)?)
};
println!(); println!();
Ok(Config { Ok(Config {
data: Data { dir: data_dir }, data: Data { dir: data_dir },
network: Network { network: Network {
listen: listen_addresses, listen: listen_addresses,
rendezvous_point, rendezvous_point: if rendezvous_point.is_empty() {
None
} else {
Some(rendezvous_point)
},
external_addresses: vec![], external_addresses: vec![],
}, },
bitcoin: Bitcoin { bitcoin: Bitcoin {
@ -358,7 +355,7 @@ mod tests {
}, },
network: Network { network: Network {
listen: vec![defaults.listen_address_tcp, defaults.listen_address_ws], listen: vec![defaults.listen_address_tcp, defaults.listen_address_ws],
rendezvous_point: Some(DEFAULT_RENDEZVOUS_ADDRESS.parse().unwrap()), rendezvous_point: None,
external_addresses: vec![], external_addresses: vec![],
}, },
@ -401,7 +398,7 @@ mod tests {
}, },
network: Network { network: Network {
listen: vec![defaults.listen_address_tcp, defaults.listen_address_ws], listen: vec![defaults.listen_address_tcp, defaults.listen_address_ws],
rendezvous_point: Some(DEFAULT_RENDEZVOUS_ADDRESS.parse().unwrap()), rendezvous_point: None,
external_addresses: vec![], external_addresses: vec![],
}, },

View File

@ -1,6 +1,6 @@
use crate::env::GetConfig; use crate::env::GetConfig;
use crate::fs::system_data_dir; use crate::fs::system_data_dir;
use crate::network::rendezvous::{XmrBtcNamespace, DEFAULT_RENDEZVOUS_ADDRESS}; use crate::network::rendezvous::XmrBtcNamespace;
use crate::{env, monero}; use crate::{env, monero};
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use bitcoin::AddressType; use bitcoin::AddressType;
@ -336,8 +336,7 @@ enum RawCommand {
ListSellers { ListSellers {
#[structopt( #[structopt(
long, long,
help = "Address of the rendezvous point you want to use to discover ASBs", help = "Address of the rendezvous point you want to use to discover ASBs"
default_value = DEFAULT_RENDEZVOUS_ADDRESS
)] )]
rendezvous_point: Multiaddr, rendezvous_point: Multiaddr,

View File

@ -1,9 +1,6 @@
use libp2p::rendezvous::Namespace; use libp2p::rendezvous::Namespace;
use std::fmt; use std::fmt;
pub const DEFAULT_RENDEZVOUS_ADDRESS: &str =
"/dnsaddr/rendezvous.coblox.tech/p2p/12D3KooWQUt9DkNZxEn2R5ymJzWj15MpG6mTW84kyd8vDaRZi46o";
#[derive(Debug, PartialEq, Clone, Copy)] #[derive(Debug, PartialEq, Clone, Copy)]
pub enum XmrBtcNamespace { pub enum XmrBtcNamespace {
Mainnet, Mainnet,