From 4194fa39ae7f8c448e5c0b1eb9fbe4dd6a79f9f3 Mon Sep 17 00:00:00 2001 From: rishflab Date: Thu, 1 Jul 2021 13:46:10 +1000 Subject: [PATCH] fixup! Create toggleable rendezvous behaviour wrapper Re-introduce default rendezvous config --- swap/src/asb/config.rs | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/swap/src/asb/config.rs b/swap/src/asb/config.rs index f9e46ba9..98e8aa2f 100644 --- a/swap/src/asb/config.rs +++ b/swap/src/asb/config.rs @@ -83,6 +83,13 @@ fn default_asb_data_dir() -> Result { .context("Could not generate default config file path") } +// TODO: update this to the actual deployed rendezvous server +// Currently set to Staging ASB on raspi +const DEFAULT_RENDEZVOUS_PEER_ID: &str = "12D3KooWPZ69DRp4wbGB3wJsxxsg1XW1EVZ2evtVwcARCF3a1nrx"; +// TODO: update this to the actual deployed rendezvous server +// Port still to be opened once running rendezvous node +const DEFAULT_RENDEZVOUS_ADDR: &str = "/ip4/141.168.172.35/tcp/7654"; + const DEFAULT_MIN_BUY_AMOUNT: f64 = 0.002f64; const DEFAULT_MAX_BUY_AMOUNT: f64 = 0.02f64; const DEFAULT_SPREAD: f64 = 0.02f64; @@ -297,6 +304,18 @@ pub fn query_user_for_initial_config(testnet: bool) -> Result { } let ask_spread = Decimal::from_f64(ask_spread).context("Unable to parse spread")?; + let rendezvous_peer_id_str = Input::with_theme(&ColorfulTheme::default()) + .with_prompt("Enter the peer id of the rendezvous node you wish to register with") + .default(DEFAULT_RENDEZVOUS_PEER_ID.to_string()) + .interact_text()?; + let rendezvous_peer_id = PeerId::from_str(rendezvous_peer_id_str.as_str())?; + + let rendezvous_addr_str = Input::with_theme(&ColorfulTheme::default()) + .with_prompt("Enter the multiaddress of the rendezvous node you wish to register with") + .default(DEFAULT_RENDEZVOUS_ADDR.to_string()) + .interact_text()?; + let rendezvous_addr = Multiaddr::from_str(rendezvous_addr_str.as_str())?; + println!(); Ok(Config { @@ -325,7 +344,10 @@ pub fn query_user_for_initial_config(testnet: bool) -> Result { ask_spread, price_ticker_ws_url: defaults.price_ticker_ws_url, }, - rendezvous: None, + rendezvous: Some(Rendezvous { + addr: rendezvous_addr, + peer_id: rendezvous_peer_id, + }), }) } @@ -367,7 +389,10 @@ mod tests { ask_spread: Decimal::from_f64(DEFAULT_SPREAD).unwrap(), price_ticker_ws_url: defaults.price_ticker_ws_url, }, - rendezvous: None, + rendezvous: Some(Rendezvous { + addr: DEFAULT_RENDEZVOUS_ADDR.parse().unwrap(), + peer_id: PeerId::from_str(DEFAULT_RENDEZVOUS_PEER_ID).unwrap(), + }), }; initial_setup(config_path.clone(), expected.clone()).unwrap(); @@ -409,7 +434,10 @@ mod tests { ask_spread: Decimal::from_f64(DEFAULT_SPREAD).unwrap(), price_ticker_ws_url: defaults.price_ticker_ws_url, }, - rendezvous: None, + rendezvous: Some(Rendezvous { + addr: DEFAULT_RENDEZVOUS_ADDR.parse().unwrap(), + peer_id: PeerId::from_str(DEFAULT_RENDEZVOUS_PEER_ID).unwrap(), + }), }; initial_setup(config_path.clone(), expected.clone()).unwrap();