From 9c13b25c067ddd94c97d9ab3683051aa2f4210c7 Mon Sep 17 00:00:00 2001 From: Xiangyi Zheng Date: Fri, 24 May 2024 18:46:06 +0800 Subject: [PATCH 1/2] fix: add port to my_address so join method works --- node/src/cli.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/node/src/cli.rs b/node/src/cli.rs index 63ef6bf49..02db18a9e 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -221,10 +221,15 @@ pub fn run(cmd: Cli) -> anyhow::Result<()> { )); let sign_sk = sign_sk.unwrap_or_else(|| account_sk.clone()); - let my_address = my_address.unwrap_or_else(|| { - let my_ip = local_ip().unwrap(); - Url::parse(&format!("http://{my_ip}:{web_port}")).unwrap() - }); + let my_address = my_address + .map(|mut addr| { + let _ = addr.set_port(Some(web_port)); + addr + }) + .unwrap_or_else(|| { + let my_ip = local_ip().unwrap(); + Url::parse(&format!("http://{my_ip}:{web_port}")).unwrap() + }); tracing::info!(%my_address, "address detected"); let rpc_client = near_fetch::Client::new(&near_rpc); tracing::debug!(rpc_addr = rpc_client.rpc_addr(), "rpc client initialized"); From 256954ab0a14a2d8817ecd0effffdcd2a26fb0a5 Mon Sep 17 00:00:00 2001 From: Xiangyi Zheng Date: Sun, 26 May 2024 15:41:34 +0800 Subject: [PATCH 2/2] fail early on incorrect url --- node/src/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/src/cli.rs b/node/src/cli.rs index 02db18a9e..0bc5f95c0 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -223,7 +223,7 @@ pub fn run(cmd: Cli) -> anyhow::Result<()> { let sign_sk = sign_sk.unwrap_or_else(|| account_sk.clone()); let my_address = my_address .map(|mut addr| { - let _ = addr.set_port(Some(web_port)); + addr.set_port(Some(web_port)).unwrap(); addr }) .unwrap_or_else(|| {