Use cluster_info to get rpc address

This commit is contained in:
Tyera Eulberg 2018-11-12 12:39:42 -07:00 committed by Tyera Eulberg
parent fa72160c95
commit 0e749dad4c
2 changed files with 2 additions and 20 deletions

View File

@ -6,7 +6,6 @@ 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;
@ -30,12 +29,6 @@ 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()
@ -63,7 +56,6 @@ pub fn parse_args(matches: &ArgMatches) -> Result<WalletConfig, Box<error::Error
network,
timeout,
proxy,
rpc_port,
})
}
@ -91,12 +83,6 @@ 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")

View File

@ -87,7 +87,6 @@ pub struct WalletConfig {
pub network: SocketAddr,
pub timeout: Option<u64>,
pub proxy: Option<String>,
pub rpc_port: u16,
}
impl Default for WalletConfig {
@ -99,7 +98,6 @@ impl Default for WalletConfig {
network: default_addr,
timeout: None,
proxy: None,
rpc_port: 0,
}
}
}
@ -111,9 +109,7 @@ impl WalletConfig {
drone_addr
}
pub fn rpc_addr(&self, tpu_addr: SocketAddr) -> String {
let mut rpc_addr = tpu_addr;
rpc_addr.set_port(self.rpc_port);
pub fn rpc_addr(&self, rpc_addr: SocketAddr) -> String {
let rpc_addr_str = format!("http://{}", rpc_addr.to_string());
self.proxy.clone().unwrap_or(rpc_addr_str)
}
@ -319,7 +315,7 @@ pub fn process_command(config: &WalletConfig) -> Result<String, Box<error::Error
let leader = poll_gossip_for_leader(config.network, config.timeout)?;
let tpu_addr = leader.contact_info.tpu;
let drone_addr = config.drone_addr(tpu_addr);
let rpc_addr = config.rpc_addr(tpu_addr);
let rpc_addr = config.rpc_addr(leader.contact_info.rpc);
match config.command {
// Get address of this client