Use cluster_info to get rpc address
This commit is contained in:
parent
fa72160c95
commit
0e749dad4c
|
@ -6,7 +6,6 @@ extern crate solana;
|
||||||
|
|
||||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||||
use solana::logger;
|
use solana::logger;
|
||||||
use solana::rpc::RPC_PORT;
|
|
||||||
use solana::signature::{read_keypair, KeypairUtil};
|
use solana::signature::{read_keypair, KeypairUtil};
|
||||||
use solana::wallet::{gen_keypair_file, parse_command, process_command, WalletConfig, WalletError};
|
use solana::wallet::{gen_keypair_file, parse_command, process_command, WalletConfig, WalletError};
|
||||||
use std::error;
|
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 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 mut path = dirs::home_dir().expect("home directory");
|
||||||
let id_path = if matches.is_present("keypair") {
|
let id_path = if matches.is_present("keypair") {
|
||||||
matches.value_of("keypair").unwrap()
|
matches.value_of("keypair").unwrap()
|
||||||
|
@ -63,7 +56,6 @@ pub fn parse_args(matches: &ArgMatches) -> Result<WalletConfig, Box<error::Error
|
||||||
network,
|
network,
|
||||||
timeout,
|
timeout,
|
||||||
proxy,
|
proxy,
|
||||||
rpc_port,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,12 +83,6 @@ fn main() -> Result<(), Box<error::Error>> {
|
||||||
.value_name("SECS")
|
.value_name("SECS")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("Max seconds to wait to get necessary gossip from the network"),
|
.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(
|
||||||
Arg::with_name("proxy")
|
Arg::with_name("proxy")
|
||||||
.long("proxy")
|
.long("proxy")
|
||||||
|
|
|
@ -87,7 +87,6 @@ pub struct WalletConfig {
|
||||||
pub network: SocketAddr,
|
pub network: SocketAddr,
|
||||||
pub timeout: Option<u64>,
|
pub timeout: Option<u64>,
|
||||||
pub proxy: Option<String>,
|
pub proxy: Option<String>,
|
||||||
pub rpc_port: u16,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for WalletConfig {
|
impl Default for WalletConfig {
|
||||||
|
@ -99,7 +98,6 @@ impl Default for WalletConfig {
|
||||||
network: default_addr,
|
network: default_addr,
|
||||||
timeout: None,
|
timeout: None,
|
||||||
proxy: None,
|
proxy: None,
|
||||||
rpc_port: 0,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,9 +109,7 @@ impl WalletConfig {
|
||||||
drone_addr
|
drone_addr
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rpc_addr(&self, tpu_addr: SocketAddr) -> String {
|
pub fn rpc_addr(&self, rpc_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());
|
let rpc_addr_str = format!("http://{}", rpc_addr.to_string());
|
||||||
self.proxy.clone().unwrap_or(rpc_addr_str)
|
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 leader = poll_gossip_for_leader(config.network, config.timeout)?;
|
||||||
let tpu_addr = leader.contact_info.tpu;
|
let tpu_addr = leader.contact_info.tpu;
|
||||||
let drone_addr = config.drone_addr(tpu_addr);
|
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 {
|
match config.command {
|
||||||
// Get address of this client
|
// Get address of this client
|
||||||
|
|
Loading…
Reference in New Issue