chore: updated the cli so that it can accept ports correctly

This commit is contained in:
Lioncat2002 2022-12-06 10:51:03 +05:30
parent 692a54b059
commit 59197c52b3
No known key found for this signature in database
3 changed files with 13 additions and 9 deletions

View File

@ -23,5 +23,5 @@ This project is currently based on an unstable feature of block subscription of
```
cargo run --bin lite-rpc -- --port 9000 --subscription-port 9001 --url http://localhost:8899
cargo run --bin lite-rpc -- --port 9000 --subscription-port 9001 --rpc-url http://localhost:8899
```

View File

@ -1,4 +1,4 @@
use {clap::Parser, solana_cli_config::ConfigInput, std::net::SocketAddr};
use {clap::Parser, solana_cli_config::ConfigInput};
/// Holds the configuration for a single run of the benchmark
#[derive(Parser, Debug)]
@ -11,10 +11,10 @@ use {clap::Parser, solana_cli_config::ConfigInput, std::net::SocketAddr};
"
)]
pub struct Args {
#[arg(short, long, default_value_t = SocketAddr::from(([127, 0, 0, 1], 9000)))]
pub port: SocketAddr,
#[arg(short, long, default_value_t = SocketAddr::from(([127, 0, 0, 1], 8900)))]
pub subscription_port: SocketAddr,
#[arg(short, long, default_value_t = String::new())]
pub port: String,
#[arg(short, long, default_value_t = String::new())]
pub subscription_port: String,
#[arg(short, long, default_value_t = String::new())]
pub rpc_url: String,
#[arg(short, long, default_value_t = String::new())]

View File

@ -1,4 +1,4 @@
use std::sync::Arc;
use std::{sync::Arc, net::SocketAddr};
use clap::Parser;
use context::LiteRpcSubsrciptionControl;
@ -42,9 +42,13 @@ pub fn main() {
notification_reciever,
));
let subscription_port = subscription_port
.parse::<SocketAddr>()
.expect("Invalid subscription port");
// start websocket server
let (_trigger, websocket_service) =
LitePubSubService::new(pubsub_control.clone(), *subscription_port);
LitePubSubService::new(pubsub_control.clone(), subscription_port);
// start recieving notifications and broadcast them
{
@ -73,7 +77,7 @@ pub fn main() {
.expect("Runtime"),
);
let max_request_body_size: usize = 50 * (1 << 10);
let socket_addr = *rpc_addr;
let socket_addr = rpc_addr.parse::<SocketAddr>().unwrap();
{
let request_processor = request_processor.clone();