Revert to a computed `websocket_url` value when `json_rpc_url` is changed

This commit is contained in:
Michael Vines 2020-03-10 14:09:59 -07:00
parent 2c4079f4c8
commit f655372b08
2 changed files with 7 additions and 1 deletions

View File

@ -31,7 +31,10 @@ impl Default for Config {
keypair_path.to_str().unwrap().to_string() keypair_path.to_str().unwrap().to_string()
}; };
let json_rpc_url = "http://127.0.0.1:8899".to_string(); let json_rpc_url = "http://127.0.0.1:8899".to_string();
let websocket_url = Self::compute_websocket_url(&json_rpc_url);
// Empty websocket_url string indicates the client should
// `Config::compute_websocket_url(&json_rpc_url)`
let websocket_url = "".to_string();
Self { Self {
json_rpc_url, json_rpc_url,

View File

@ -55,6 +55,9 @@ fn parse_settings(matches: &ArgMatches<'_>) -> Result<bool, Box<dyn error::Error
let mut config = Config::load(config_file).unwrap_or_default(); let mut config = Config::load(config_file).unwrap_or_default();
if let Some(url) = subcommand_matches.value_of("json_rpc_url") { if let Some(url) = subcommand_matches.value_of("json_rpc_url") {
config.json_rpc_url = url.to_string(); config.json_rpc_url = url.to_string();
// Revert to a computed `websocket_url` value when `json_rpc_url` is
// changed
config.websocket_url = "".to_string();
} }
if let Some(url) = subcommand_matches.value_of("websocket_url") { if let Some(url) = subcommand_matches.value_of("websocket_url") {
config.websocket_url = url.to_string(); config.websocket_url = url.to_string();