From fc55835932b11dffd17138844f9d2ae9c82ad4cd Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Fri, 9 Nov 2018 17:27:36 -0700 Subject: [PATCH] Revert "Boot rpc_port" This reverts commit 1984b6db06dae4f6b655b9076e657e389d786105. --- src/bin/wallet.rs | 14 ++++++++++++++ src/wallet.rs | 18 ++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/bin/wallet.rs b/src/bin/wallet.rs index 31bd93bcd..f56b2568e 100644 --- a/src/bin/wallet.rs +++ b/src/bin/wallet.rs @@ -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 Result Result<(), Box> { .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") diff --git a/src/wallet.rs b/src/wallet.rs index 78497661f..f7d61b4a6 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -89,6 +89,7 @@ pub struct WalletConfig { pub network: SocketAddr, pub timeout: Option, pub proxy: Option, + 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