improve ws_addr arg handling

This commit is contained in:
GroovieGermanikus 2024-06-20 13:31:53 +02:00
parent 04580abbe7
commit 819164671b
No known key found for this signature in database
GPG Key ID: 5B6EB831A5CD2015
2 changed files with 9 additions and 7 deletions

View File

@ -12,18 +12,21 @@ use url::Url;
pub async fn benchnew_confirmation_rate_servicerunner(
bench_config: &BenchConfig,
rpc_addr: String,
tx_status_websocket_addr: String,
tx_status_websocket_addr: Option<String>,
funded_payer: Keypair,
) -> confirmation_rate::Metric {
let rpc = Arc::new(RpcClient::new(rpc_addr));
let rpc = Arc::new(RpcClient::new(rpc_addr.clone()));
let tx_params = BenchmarkTransactionParams {
tx_size: bench_config.tx_size,
cu_price_micro_lamports: bench_config.cu_price_micro_lamports,
};
let max_timeout = Duration::from_secs(60);
let ws_addr = tx_status_websocket_addr.unwrap_or_else(|| rpc_addr.replace("http:", "ws:").replace("https:", "wss:"));
let result = send_bulk_txs_and_wait(
&rpc,
Url::parse(&tx_status_websocket_addr).expect("Invalid URL"),
Url::parse(&ws_addr).expect("Invalid WS URL"),
&funded_payer,
bench_config.tx_count,
&tx_params,

View File

@ -7,7 +7,7 @@ pub struct TenantConfig {
pub tenant_id: String,
pub rpc_addr: String,
// needs to point to a reliable websocket server that can be used to get tx status
pub tx_status_ws_addr: String,
pub tx_status_ws_addr: Option<String>,
}
// recommend to use one payer keypair for all targets and fund that keypair with enough SOL
@ -56,10 +56,9 @@ pub fn read_tenant_configs(env_vars: Vec<(String, String)>) -> Vec<TenantConfig>
.iter()
.find(|(v, _)| *v == format!("TENANT{}_TX_STATUS_WS_ADDR", tc))
.iter()
.exactly_one()
.at_most_one()
.expect("need TENANT_X_TX_STATUS_WS_ADDR")
.1
.to_string(),
.map(|(_, v)| v.to_string())
})
.collect::<Vec<TenantConfig>>();