From ce33997706de1cb6d0d36d6c117c6f779e0a2d55 Mon Sep 17 00:00:00 2001 From: buffalu <85544055+buffalu@users.noreply.github.com> Date: Thu, 1 Sep 2022 11:28:27 -0500 Subject: [PATCH] Split arguments separated by spaces (#31) --- transaction-relayer/src/main.rs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/transaction-relayer/src/main.rs b/transaction-relayer/src/main.rs index f5a682564a62ef..f3a55bfc382e7b 100644 --- a/transaction-relayer/src/main.rs +++ b/transaction-relayer/src/main.rs @@ -72,13 +72,13 @@ struct Args { #[clap(long, env, value_parser, default_value_t = 16)] num_tpu_fwd_binds: usize, - /// RPC server list + /// RPC servers as a space-separated list. Shall be same position as websocket equivalent below #[clap(long, env, value_parser, default_value = "http://127.0.0.1:8899")] - rpc_servers: Vec, + rpc_servers: String, - /// Websocket server list + /// Websocket servers as a space-separated list. Shall be same position as RPC equivalent above #[clap(long, env, value_parser, default_value = "ws://127.0.0.1:8900")] - websocket_servers: Vec, + websocket_servers: String, /// This is the IP address that will be shared with the validator. The validator will /// tell the rest of the network to send packets here. @@ -189,6 +189,7 @@ fn main() { env_logger::init(); let args: Args = Args::parse(); + info!("args: {:?}", args); let sockets = get_sockets(&args); @@ -199,17 +200,25 @@ fn main() { let exit = Arc::new(AtomicBool::new(false)); + let rpc_servers: Vec = args.rpc_servers.split(' ').map(String::from).collect(); + let websocket_servers: Vec = args + .websocket_servers + .split(' ') + .map(String::from) + .collect(); + info!("rpc servers: {:?}", rpc_servers); + info!("ws servers: {:?}", websocket_servers); + + assert!(!rpc_servers.is_empty(), "num rpc servers >= 1"); assert_eq!( - args.rpc_servers.len(), - args.websocket_servers.len(), + rpc_servers.len(), + websocket_servers.len(), "num rpc servers = num websocket servers" ); - assert!(!args.rpc_servers.is_empty(), "num rpc servers >= 1"); - let servers: Vec<(String, String)> = args - .rpc_servers + let servers: Vec<(String, String)> = rpc_servers .into_iter() - .zip(args.websocket_servers.into_iter()) + .zip(websocket_servers.into_iter()) .collect(); let (rpc_load_balancer, slot_receiver) = LoadBalancer::new(&servers, &exit);