Attempt fix for addr parsing

This commit is contained in:
Paul Hauner
2019-11-23 15:20:29 +11:00
parent 466eb0420f
commit 68942318a7
4 changed files with 111 additions and 153 deletions

View File

@@ -9,14 +9,6 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
/* /*
* Configuration directory locations. * Configuration directory locations.
*/ */
.arg(
Arg::with_name("datadir")
.long("datadir")
.value_name("DIR")
.help("Data directory for keys and databases.")
.takes_value(true)
.global(true)
)
.arg( .arg(
Arg::with_name("network-dir") Arg::with_name("network-dir")
.long("network-dir") .long("network-dir")

View File

@@ -12,7 +12,6 @@ use reqwest::{
use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde::{de::DeserializeOwned, Deserialize, Serialize};
use ssz::Encode; use ssz::Encode;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::net::SocketAddr;
use std::time::Duration; use std::time::Duration;
use types::{ use types::{
Attestation, BeaconBlock, BeaconState, CommitteeIndex, Epoch, EthSpec, Fork, Hash256, Attestation, BeaconBlock, BeaconState, CommitteeIndex, Epoch, EthSpec, Fork, Hash256,
@@ -36,9 +35,9 @@ pub struct RemoteBeaconNode<E: EthSpec> {
} }
impl<E: EthSpec> RemoteBeaconNode<E> { impl<E: EthSpec> RemoteBeaconNode<E> {
pub fn new(http_endpoint: SocketAddr) -> Result<Self, String> { pub fn new(http_endpoint: String) -> Result<Self, String> {
Ok(Self { Ok(Self {
http: HttpClient::new(format!("http://{}", http_endpoint.to_string())) http: HttpClient::new(http_endpoint)
.map_err(|e| format!("Unable to create http client: {:?}", e))?, .map_err(|e| format!("Unable to create http client: {:?}", e))?,
}) })
} }

View File

@@ -15,34 +15,9 @@ lazy_static! {
} }
pub fn cli_app<'a, 'b>() -> App<'a, 'b> { pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
App::new("Validator Client") App::new("validator_client")
.visible_aliases(&["v", "vc", "validator", "validator_client"]) .visible_aliases(&["v", "vc", "validator"])
.version("0.0.1") .about("Ethereum 2.0 Validator Client")
.author("Sigma Prime <contact@sigmaprime.io>")
.about("Eth 2.0 Validator Client")
.arg(
Arg::with_name("datadir")
.long("datadir")
.short("d")
.value_name("DIR")
.help("Data directory for keys and databases.")
.takes_value(true),
)
.arg(
Arg::with_name("logfile")
.long("logfile")
.value_name("logfile")
.help("File path where output will be written.")
.takes_value(true),
)
.arg(
Arg::with_name("eth2-config")
.long("eth2-config")
.short("e")
.value_name("TOML_FILE")
.help("Path to Ethereum 2.0 config and specification file (e.g., eth2_spec.toml).")
.takes_value(true),
)
.arg( .arg(
Arg::with_name("server") Arg::with_name("server")
.long("server") .long("server")

View File

@@ -69,29 +69,21 @@ impl<T: EthSpec> ProductionValidatorClient<T> {
let log_2 = context.log.clone(); let log_2 = context.log.clone();
let log_3 = context.log.clone(); let log_3 = context.log.clone();
let http_server_addr = format!(
"http://{}:{}",
client_config.server, client_config.server_http_port
);
info!( info!(
log_1, log_1,
"Starting validator client"; "Starting validator client";
"beacon_node" => &http_server_addr,
"datadir" => format!("{:?}", client_config.data_dir), "datadir" => format!("{:?}", client_config.data_dir),
); );
format!(
"{}:{}",
client_config.server, client_config.server_http_port
)
.parse()
.map_err(|e| format!("Unable to parse server address: {:?}", e))
.into_future()
.and_then(move |http_server_addr| {
info!(
log_1,
"Beacon node connection info";
"http_server" => format!("{}", http_server_addr),
);
RemoteBeaconNode::new(http_server_addr) RemoteBeaconNode::new(http_server_addr)
.map_err(|e| format!("Unable to init beacon node http client: {}", e)) .map_err(|e| format!("Unable to init beacon node http client: {}", e))
}) .into_future()
.and_then(move |beacon_node| wait_for_node(beacon_node, log_2)) .and_then(move |beacon_node| wait_for_node(beacon_node, log_2))
.and_then(|beacon_node| { .and_then(|beacon_node| {
beacon_node beacon_node