mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 06:21:02 +00:00
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:
committed by
Bastian Köcher
parent
30a0338717
commit
018d6d8d1a
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user