2022-12-05 21:21:03 -08:00
|
|
|
use {clap::Parser, solana_cli_config::ConfigInput};
|
2022-11-12 05:32:01 -08:00
|
|
|
|
|
|
|
/// Holds the configuration for a single run of the benchmark
|
2022-11-30 07:56:41 -08:00
|
|
|
#[derive(Parser, Debug)]
|
|
|
|
#[command(
|
|
|
|
version,
|
|
|
|
about = "A lite version of solana rpc to send and confirm transactions.",
|
|
|
|
long_about = "Lite rpc is optimized to send and confirm transactions for solana blockchain. \
|
|
|
|
When it recieves a transaction it will directly send it to next few leaders. It then adds the signature into internal map. It listen to block subscriptions for confirmed and finalized blocks. \
|
|
|
|
It also has a websocket port for subscription to onSlotChange and onSignature subscriptions. \
|
|
|
|
"
|
|
|
|
)]
|
|
|
|
pub struct Args {
|
2022-12-07 06:05:37 -08:00
|
|
|
#[arg(short, long, default_value_t = String::from("8899"))]
|
2022-12-05 21:21:03 -08:00
|
|
|
pub port: String,
|
2022-12-05 21:24:20 -08:00
|
|
|
#[arg(short, long, default_value_t = String::from("8900"))]
|
2022-12-05 21:21:03 -08:00
|
|
|
pub subscription_port: String,
|
2022-12-05 21:24:20 -08:00
|
|
|
#[arg(short, long, default_value_t = String::from("http://localhost:8899"))]
|
2022-11-30 07:56:41 -08:00
|
|
|
pub rpc_url: String,
|
|
|
|
#[arg(short, long, default_value_t = String::new())]
|
2022-11-12 05:32:01 -08:00
|
|
|
pub websocket_url: String,
|
|
|
|
}
|
|
|
|
|
2022-11-30 07:56:41 -08:00
|
|
|
impl Args {
|
|
|
|
pub fn resolve_address(&mut self) {
|
|
|
|
if self.rpc_url.is_empty() {
|
|
|
|
let (_, rpc_url) = ConfigInput::compute_json_rpc_url_setting(
|
|
|
|
self.rpc_url.as_str(),
|
|
|
|
&ConfigInput::default().json_rpc_url,
|
|
|
|
);
|
|
|
|
self.rpc_url = rpc_url;
|
|
|
|
}
|
|
|
|
if self.websocket_url.is_empty() {
|
|
|
|
let (_, ws_url) = ConfigInput::compute_websocket_url_setting(
|
|
|
|
&self.websocket_url.as_str(),
|
|
|
|
"",
|
|
|
|
self.rpc_url.as_str(),
|
|
|
|
"",
|
|
|
|
);
|
|
|
|
self.websocket_url = ws_url;
|
2022-11-12 05:32:01 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|