Overhaul wallet rpc/drone command-line arguments

This commit is contained in:
Michael Vines
2019-01-16 20:43:00 -08:00
parent 00c4c30d72
commit a84b6bc7e4
10 changed files with 220 additions and 126 deletions

View File

@@ -507,7 +507,7 @@ mod tests {
let thread = rpc_service.thread_hdl.thread();
assert_eq!(thread.name().unwrap(), "solana-jsonrpc");
let rpc_string = get_rpc_request_str(rpc_addr);
let rpc_string = get_rpc_request_str(rpc_addr, false);
let client = reqwest::Client::new();
let request = json!({
"jsonrpc": "2.0",
@@ -755,7 +755,7 @@ mod tests {
"params": json!([serial_tx])
});
let rpc_addr = leader_data.rpc;
let rpc_string = get_rpc_request_str(rpc_addr);
let rpc_string = get_rpc_request_str(rpc_addr, false);
let mut response = client
.post(&rpc_string)
.header(CONTENT_TYPE, "application/json")

View File

@@ -21,7 +21,7 @@ impl RpcClient {
}
pub fn new_with_timeout(addr: SocketAddr, timeout: Duration) -> Self {
let addr = get_rpc_request_str(addr);
let addr = get_rpc_request_str(addr, false);
let client = reqwest::Client::builder()
.timeout(timeout)
.build()
@@ -30,7 +30,7 @@ impl RpcClient {
}
pub fn new_from_socket(addr: SocketAddr) -> Self {
Self::new(get_rpc_request_str(addr))
Self::new(get_rpc_request_str(addr, false))
}
pub fn retry_make_rpc_request(
@@ -77,8 +77,12 @@ impl RpcClient {
}
}
pub fn get_rpc_request_str(rpc_addr: SocketAddr) -> String {
format!("http://{}", rpc_addr)
pub fn get_rpc_request_str(rpc_addr: SocketAddr, tls: bool) -> String {
if tls {
format!("https://{}", rpc_addr)
} else {
format!("http://{}", rpc_addr)
}
}
pub trait RpcRequestHandler {