Some relayer improvments (#2902)

* added CLI arguments: full WS URI + separate for WS path URI component + additional log

* URI -> URL?

* added TODO

* fmt
This commit is contained in:
Svyatoslav Nikolsky
2024-04-01 12:30:39 +03:00
committed by Bastian Köcher
parent 30a0338717
commit 018d6d8d1a
5 changed files with 51 additions and 8 deletions
+16 -6
View File
@@ -264,12 +264,22 @@ impl<C: Chain> Client<C> {
params: &ConnectionParams,
) -> Result<(Arc<tokio::runtime::Runtime>, Arc<RpcClient>)> {
let tokio = tokio::runtime::Runtime::new()?;
let uri = format!(
"{}://{}:{}",
if params.secure { "wss" } else { "ws" },
params.host,
params.port,
);
let uri = match params.uri {
Some(ref uri) => uri.clone(),
None => {
format!(
"{}://{}:{}{}",
if params.secure { "wss" } else { "ws" },
params.host,
params.port,
match params.path {
Some(ref path) => format!("/{}", path),
None => String::new(),
},
)
},
};
log::info!(target: "bridge", "Connecting to {} node at {}", C::NAME, uri);
let client = tokio
@@ -57,10 +57,15 @@ pub use bp_runtime::{
/// Substrate-over-websocket connection params.
#[derive(Debug, Clone)]
pub struct ConnectionParams {
/// Websocket endpoint URL. Overrides all other URL components (`host`, `port`, `path` and
/// `secure`).
pub uri: Option<String>,
/// Websocket server host name.
pub host: String,
/// Websocket server TCP port.
pub port: u16,
/// Websocket endpoint path at server.
pub path: Option<String>,
/// Use secure websocket connection.
pub secure: bool,
/// Defined chain runtime version
@@ -70,8 +75,10 @@ pub struct ConnectionParams {
impl Default for ConnectionParams {
fn default() -> Self {
ConnectionParams {
uri: None,
host: "localhost".into(),
port: 9944,
path: None,
secure: false,
chain_runtime_version: ChainRuntimeVersion::Auto,
}