From 62c5ad6f7e166c15e2bd4c77698236d0e960fd0a Mon Sep 17 00:00:00 2001 From: Dmitry Lavrenov Date: Wed, 13 Mar 2024 16:56:31 +0300 Subject: [PATCH] [substrate-apply] humanode-peer:cli:config: rpc server: break legacy CLI options and remove backward compatible HTTP server --- crates/humanode-peer/src/cli/config.rs | 36 +++++++------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/crates/humanode-peer/src/cli/config.rs b/crates/humanode-peer/src/cli/config.rs index aa5da88fc..172cdba3c 100644 --- a/crates/humanode-peer/src/cli/config.rs +++ b/crates/humanode-peer/src/cli/config.rs @@ -29,9 +29,8 @@ pub trait CliConfigurationExt: SubstrateCliConfigurationProvider { .unwrap_or_default(); let bioauth_flow = self.bioauth_params().map(|params| { - let rpc_http_port = substrate.rpc_http.map(|v| v.port()); - let rpc_ws_port = substrate.rpc_ws.map(|v| v.port()); - let rpc_url = rpc_url_from_params(params, rpc_http_port, rpc_ws_port); + let rpc_port = substrate.rpc_addr.map(|v| v.port()); + let rpc_url = rpc_url_from_params(params, rpc_port); configuration::BioauthFlow { rpc_url_resolver: Default::default(), @@ -124,11 +123,7 @@ impl SubstrateCliConfigurationProvider for T { } /// Construct an RPC URL from the bioauth flow params and an RPC endpoint port. -fn rpc_url_from_params( - params: &BioauthFlowParams, - rpc_http_port: Option, - rpc_ws_port: Option, -) -> RpcUrl { +fn rpc_url_from_params(params: &BioauthFlowParams, rpc_port: Option) -> RpcUrl { if let Some(val) = ¶ms.rpc_url { return RpcUrl::Set(val.clone()); } @@ -136,36 +131,25 @@ fn rpc_url_from_params( return RpcUrl::Unset; } if params.rpc_url_ngrok_detect { - let ws_rpc_endpoint_port = match params.rpc_url_scheme_preference { - // If there's no preference - try switching to WebSocket if it's available. - RpcUrlSchemePreference::NoPreference | RpcUrlSchemePreference::Ws => rpc_ws_port, - RpcUrlSchemePreference::Http => None, - }; return RpcUrl::DetectFromNgrok { tunnel_name: params.rpc_url_ngrok_detect_from.clone(), - ws_rpc_endpoint_port, + ws_rpc_endpoint_port: rpc_port, }; } - match ( - ¶ms.rpc_url_scheme_preference, - rpc_http_port, - rpc_ws_port, - ) { + match (¶ms.rpc_url_scheme_preference, rpc_port) { // Try WebSocket first if the user has no preference. - (RpcUrlSchemePreference::Ws | RpcUrlSchemePreference::NoPreference, _, Some(port)) => { + (RpcUrlSchemePreference::Ws | RpcUrlSchemePreference::NoPreference, Some(port)) => { RpcUrl::LocalhostWithPort { rpc_endpoint_port: port, scheme: "ws", } } // Try HTTP second if the user has no preference. - (RpcUrlSchemePreference::Http | RpcUrlSchemePreference::NoPreference, Some(port), _) => { - RpcUrl::LocalhostWithPort { - rpc_endpoint_port: port, - scheme: "http", - } - } + (RpcUrlSchemePreference::Http, Some(port)) => RpcUrl::LocalhostWithPort { + rpc_endpoint_port: port, + scheme: "http", + }, // If everything fails - fallback to unset. _ => RpcUrl::Unset, }