diff --git a/client/src/client.rs b/client/src/client.rs index 540dbc965b..2581eeaeda 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -13,5 +13,5 @@ pub fn create_client_with_timeout( timeout: Duration, ) -> ThinClient { let (_, transactions_socket) = solana_netutil::bind_in_range(range).unwrap(); - ThinClient::new_with_timeout(rpc, tpu, transactions_socket, timeout) + ThinClient::new_socket_with_timeout(rpc, tpu, transactions_socket, timeout) } diff --git a/client/src/rpc_mock.rs b/client/src/rpc_mock.rs index ba18f3b614..cac1b1b2cf 100644 --- a/client/src/rpc_mock.rs +++ b/client/src/rpc_mock.rs @@ -17,12 +17,12 @@ pub const SIGNATURE: &str = #[derive(Clone)] pub struct MockRpcClient { - pub addr: String, + pub url: String, } impl MockRpcClient { - pub fn new(addr: String) -> Self { - MockRpcClient { addr } + pub fn new(url: String) -> Self { + MockRpcClient { url } } pub fn retry_get_balance( @@ -45,7 +45,7 @@ impl MockRpcClient { params: Option, mut _retries: usize, ) -> Result> { - if self.addr == "fails" { + if self.url == "fails" { return Ok(Value::Null); } let val = match request { @@ -61,14 +61,14 @@ impl MockRpcClient { } } RpcRequest::GetBalance => { - let n = if self.addr == "airdrop" { 0 } else { 50 }; + let n = if self.url == "airdrop" { 0 } else { 50 }; Value::Number(Number::from(n)) } RpcRequest::GetRecentBlockhash => Value::String(PUBKEY.to_string()), RpcRequest::GetSignatureStatus => { - let str = if self.addr == "account_in_use" { + let str = if self.url == "account_in_use" { "AccountInUse" - } else if self.addr == "bad_sig_status" { + } else if self.url == "bad_sig_status" { "Nonexistent" } else { "Confirmed" diff --git a/client/src/rpc_request.rs b/client/src/rpc_request.rs index 3690f64696..c621bf4250 100644 --- a/client/src/rpc_request.rs +++ b/client/src/rpc_request.rs @@ -13,27 +13,27 @@ use solana_sdk::pubkey::Pubkey; #[derive(Clone)] pub struct RpcClient { pub client: reqwest::Client, - pub addr: String, + pub url: String, } impl RpcClient { - pub fn new(addr: String) -> Self { + pub fn new(url: String) -> Self { RpcClient { client: reqwest::Client::new(), - addr, + url, } } - pub fn new_with_timeout(addr: SocketAddr, timeout: Duration) -> Self { - let addr = get_rpc_request_str(addr, false); + pub fn new_socket_with_timeout(addr: SocketAddr, timeout: Duration) -> Self { + let url = get_rpc_request_str(addr, false); let client = reqwest::Client::builder() .timeout(timeout) .build() .expect("build rpc client"); - RpcClient { client, addr } + RpcClient { client, url } } - pub fn new_from_socket(addr: SocketAddr) -> Self { + pub fn new_socket(addr: SocketAddr) -> Self { Self::new(get_rpc_request_str(addr, false)) } @@ -62,7 +62,7 @@ impl RpcClient { loop { match self .client - .post(&self.addr) + .post(&self.url) .header(CONTENT_TYPE, "application/json") .body(request_json.to_string()) .send() @@ -269,7 +269,7 @@ mod tests { }); let rpc_addr = receiver.recv().unwrap(); - let rpc_client = RpcClient::new_from_socket(rpc_addr); + let rpc_client = RpcClient::new_socket(rpc_addr); let balance = rpc_client.make_rpc_request( 1, @@ -318,7 +318,7 @@ mod tests { }); let rpc_addr = receiver.recv().unwrap(); - let rpc_client = RpcClient::new_from_socket(rpc_addr); + let rpc_client = RpcClient::new_socket(rpc_addr); let balance = rpc_client.retry_make_rpc_request( 1, diff --git a/client/src/thin_client.rs b/client/src/thin_client.rs index e29d4aafb2..8444e6b396 100644 --- a/client/src/thin_client.rs +++ b/client/src/thin_client.rs @@ -45,17 +45,17 @@ impl ThinClient { rpc_addr, transactions_addr, transactions_socket, - RpcClient::new_from_socket(rpc_addr), + RpcClient::new_socket(rpc_addr), ) } - pub fn new_with_timeout( + pub fn new_socket_with_timeout( rpc_addr: SocketAddr, transactions_addr: SocketAddr, transactions_socket: UdpSocket, timeout: Duration, ) -> Self { - let rpc_client = RpcClient::new_with_timeout(rpc_addr, timeout); + let rpc_client = RpcClient::new_socket_with_timeout(rpc_addr, timeout); Self::new_from_client(rpc_addr, transactions_addr, transactions_socket, rpc_client) } diff --git a/core/src/replicator.rs b/core/src/replicator.rs index 78db00d100..bade4f5d9d 100644 --- a/core/src/replicator.rs +++ b/core/src/replicator.rs @@ -354,7 +354,7 @@ impl Replicator { let rpc_peers = cluster_info.rpc_peers(); debug!("rpc peers: {:?}", rpc_peers); let node_idx = thread_rng().gen_range(0, rpc_peers.len()); - RpcClient::new_from_socket(rpc_peers[node_idx].rpc) + RpcClient::new_socket(rpc_peers[node_idx].rpc) }; let storage_blockhash = rpc_client .make_rpc_request(2, RpcRequest::GetStorageBlockhash, None) diff --git a/core/src/voting_keypair.rs b/core/src/voting_keypair.rs index 24f5e99376..337f94b861 100644 --- a/core/src/voting_keypair.rs +++ b/core/src/voting_keypair.rs @@ -15,7 +15,7 @@ pub struct RemoteVoteSigner { impl RemoteVoteSigner { pub fn new(signer: SocketAddr) -> Self { - let rpc_client = RpcClient::new_from_socket(signer); + let rpc_client = RpcClient::new_socket(signer); Self { rpc_client } } } diff --git a/tests/thin_client.rs b/tests/thin_client.rs index 087920a682..c7420f3012 100644 --- a/tests/thin_client.rs +++ b/tests/thin_client.rs @@ -140,7 +140,7 @@ fn test_transaction_count() { let addr = "0.0.0.0:1234".parse().unwrap(); let transactions_socket = UdpSocket::bind("0.0.0.0:0").unwrap(); let mut client = - ThinClient::new_with_timeout(addr, addr, transactions_socket, Duration::from_secs(2)); + ThinClient::new_socket_with_timeout(addr, addr, transactions_socket, Duration::from_secs(2)); assert_eq!(client.transaction_count(), 0); } diff --git a/wallet/tests/deploy.rs b/wallet/tests/deploy.rs index 1ccdebca67..c6d03eab3d 100644 --- a/wallet/tests/deploy.rs +++ b/wallet/tests/deploy.rs @@ -25,7 +25,7 @@ fn test_wallet_deploy_program() { run_local_drone(alice, sender); let drone_addr = receiver.recv().unwrap(); - let rpc_client = RpcClient::new_from_socket(leader_data.rpc); + let rpc_client = RpcClient::new_socket(leader_data.rpc); let mut config = WalletConfig::default(); config.drone_port = drone_addr.port(); diff --git a/wallet/tests/pay.rs b/wallet/tests/pay.rs index 6075b6aeb1..c202abd4d6 100644 --- a/wallet/tests/pay.rs +++ b/wallet/tests/pay.rs @@ -27,7 +27,7 @@ fn test_wallet_timestamp_tx() { run_local_drone(alice, sender); let drone_addr = receiver.recv().unwrap(); - let rpc_client = RpcClient::new_from_socket(leader_data.rpc); + let rpc_client = RpcClient::new_socket(leader_data.rpc); let mut config_payer = WalletConfig::default(); config_payer.drone_port = drone_addr.port(); @@ -87,7 +87,7 @@ fn test_wallet_witness_tx() { run_local_drone(alice, sender); let drone_addr = receiver.recv().unwrap(); - let rpc_client = RpcClient::new_from_socket(leader_data.rpc); + let rpc_client = RpcClient::new_socket(leader_data.rpc); let mut config_payer = WalletConfig::default(); config_payer.drone_port = drone_addr.port(); @@ -144,7 +144,7 @@ fn test_wallet_cancel_tx() { run_local_drone(alice, sender); let drone_addr = receiver.recv().unwrap(); - let rpc_client = RpcClient::new_from_socket(leader_data.rpc); + let rpc_client = RpcClient::new_socket(leader_data.rpc); let mut config_payer = WalletConfig::default(); config_payer.drone_port = drone_addr.port(); diff --git a/wallet/tests/request_airdrop.rs b/wallet/tests/request_airdrop.rs index 5d723b09fa..a59a5ea030 100644 --- a/wallet/tests/request_airdrop.rs +++ b/wallet/tests/request_airdrop.rs @@ -21,7 +21,7 @@ fn test_wallet_request_airdrop() { let sig_response = process_command(&bob_config); sig_response.unwrap(); - let rpc_client = RpcClient::new_from_socket(leader_data.rpc); + let rpc_client = RpcClient::new_socket(leader_data.rpc); let balance = rpc_client .retry_get_balance(1, &bob_config.id.pubkey(), 1)