Revert "Boot rpc_port"
This reverts commit 1984b6db06dae4f6b655b9076e657e389d786105.
This commit is contained in:
parent
3772910bf2
commit
fc55835932
|
@ -6,6 +6,7 @@ extern crate solana;
|
|||
|
||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||
use solana::logger;
|
||||
use solana::rpc::RPC_PORT;
|
||||
use solana::signature::{read_keypair, KeypairUtil};
|
||||
use solana::wallet::{gen_keypair_file, parse_command, process_command, WalletConfig, WalletError};
|
||||
use std::error;
|
||||
|
@ -29,6 +30,12 @@ pub fn parse_args(matches: &ArgMatches) -> Result<WalletConfig, Box<error::Error
|
|||
|
||||
let proxy = matches.value_of("proxy").map(|proxy| proxy.to_string());
|
||||
|
||||
let rpc_port = if let Some(port) = matches.value_of("rpc-port") {
|
||||
port.to_string().parse().expect("integer")
|
||||
} else {
|
||||
RPC_PORT
|
||||
};
|
||||
|
||||
let mut path = dirs::home_dir().expect("home directory");
|
||||
let id_path = if matches.is_present("keypair") {
|
||||
matches.value_of("keypair").unwrap()
|
||||
|
@ -56,6 +63,7 @@ pub fn parse_args(matches: &ArgMatches) -> Result<WalletConfig, Box<error::Error
|
|||
network,
|
||||
timeout,
|
||||
proxy,
|
||||
rpc_port,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -83,6 +91,12 @@ fn main() -> Result<(), Box<error::Error>> {
|
|||
.value_name("SECS")
|
||||
.takes_value(true)
|
||||
.help("Max seconds to wait to get necessary gossip from the network"),
|
||||
).arg(
|
||||
Arg::with_name("rpc-port")
|
||||
.long("port")
|
||||
.takes_value(true)
|
||||
.value_name("NUM")
|
||||
.help("Optional rpc-port configuration to connect to non-default nodes")
|
||||
).arg(
|
||||
Arg::with_name("proxy")
|
||||
.long("proxy")
|
||||
|
|
|
@ -89,6 +89,7 @@ pub struct WalletConfig {
|
|||
pub network: SocketAddr,
|
||||
pub timeout: Option<u64>,
|
||||
pub proxy: Option<String>,
|
||||
pub rpc_port: u16,
|
||||
}
|
||||
|
||||
impl Default for WalletConfig {
|
||||
|
@ -100,6 +101,7 @@ impl Default for WalletConfig {
|
|||
network: default_addr,
|
||||
timeout: None,
|
||||
proxy: None,
|
||||
rpc_port: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,6 +112,13 @@ impl WalletConfig {
|
|||
drone_addr.set_port(DRONE_PORT);
|
||||
drone_addr
|
||||
}
|
||||
|
||||
pub fn rpc_addr(&self, tpu_addr: SocketAddr) -> String {
|
||||
let mut rpc_addr = tpu_addr;
|
||||
rpc_addr.set_port(self.rpc_port);
|
||||
let rpc_addr_str = format!("http://{}", rpc_addr.to_string());
|
||||
self.proxy.clone().unwrap_or(rpc_addr_str)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_command(
|
||||
|
@ -310,12 +319,9 @@ pub fn process_command(config: &WalletConfig) -> Result<String, Box<error::Error
|
|||
}
|
||||
|
||||
let leader = poll_gossip_for_leader(config.network, config.timeout)?;
|
||||
let leader_info = &leader.contact_info;
|
||||
let drone_addr = config.drone_addr(leader_info.tpu);
|
||||
let rpc_addr = config
|
||||
.proxy
|
||||
.clone()
|
||||
.unwrap_or_else(|| leader_info.rpc.to_string());
|
||||
let tpu_addr = leader.contact_info.tpu;
|
||||
let drone_addr = config.drone_addr(tpu_addr);
|
||||
let rpc_addr = config.rpc_addr(tpu_addr);
|
||||
|
||||
match config.command {
|
||||
// Get address of this client
|
||||
|
|
Loading…
Reference in New Issue