diff --git a/src/bank.rs b/src/bank.rs index aa0a127f54..a78d06a9fc 100644 --- a/src/bank.rs +++ b/src/bank.rs @@ -898,11 +898,11 @@ impl Bank { self.accounts.hash_internal_state() } - pub fn confirmation(&self) -> usize { + pub fn confirmation_time(&self) -> usize { self.confirmation_time.load(Ordering::Relaxed) } - pub fn set_confirmation(&self, confirmation: usize) { + pub fn set_confirmation_time(&self, confirmation: usize) { self.confirmation_time .store(confirmation, Ordering::Relaxed); } @@ -1432,11 +1432,11 @@ mod tests { assert_eq!(bank0.hash_internal_state(), bank1.hash_internal_state()); } #[test] - fn test_confirmation() { + fn test_confirmation_time() { let def_bank = Bank::default(); - assert_eq!(def_bank.confirmation(), std::usize::MAX); - def_bank.set_confirmation(90); - assert_eq!(def_bank.confirmation(), 90); + assert_eq!(def_bank.confirmation_time(), std::usize::MAX); + def_bank.set_confirmation_time(90); + assert_eq!(def_bank.confirmation_time(), 90); } #[test] fn test_interleaving_locks() { diff --git a/src/compute_leader_confirmation_service.rs b/src/compute_leader_confirmation_service.rs index 4e4746c8be..62c868374b 100755 --- a/src/compute_leader_confirmation_service.rs +++ b/src/compute_leader_confirmation_service.rs @@ -106,7 +106,7 @@ impl ComputeLeaderConfirmationService { let confirmation_ms = now - super_majority_timestamp; *last_valid_validator_timestamp = super_majority_timestamp; - bank.set_confirmation((now - *last_valid_validator_timestamp) as usize); + bank.set_confirmation_time((now - *last_valid_validator_timestamp) as usize); submit( influxdb::Point::new(&"leader-confirmation") @@ -220,7 +220,7 @@ pub mod tests { dummy_leader_id, &mut last_confirmation_time, ); - assert_eq!(bank.confirmation(), std::usize::MAX); + assert_eq!(bank.confirmation_time(), std::usize::MAX); // Get another validator to vote, so we now have 2/3 consensus let vote_account = &vote_accounts[7]; @@ -233,7 +233,7 @@ pub mod tests { dummy_leader_id, &mut last_confirmation_time, ); - assert!(bank.confirmation() != std::usize::MAX); + assert!(bank.confirmation_time() != std::usize::MAX); assert!(last_confirmation_time > 0); } } diff --git a/src/rpc.rs b/src/rpc.rs index 0d059fdf7d..b506f4aa57 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -135,8 +135,8 @@ build_rpc_trait! { #[rpc(meta, name = "getBalance")] fn get_balance(&self, Self::Metadata, String) -> Result; - #[rpc(meta, name = "getConfirmation")] - fn get_confirmation(&self, Self::Metadata) -> Result; + #[rpc(meta, name = "getConfirmationTime")] + fn get_confirmation_time(&self, Self::Metadata) -> Result; #[rpc(meta, name = "getLastId")] fn get_last_id(&self, Self::Metadata) -> Result; @@ -184,9 +184,9 @@ impl RpcSol for RpcSolImpl { let pubkey = verify_pubkey(id)?; meta.request_processor.get_balance(pubkey) } - fn get_confirmation(&self, meta: Self::Metadata) -> Result { - info!("get_confirmation rpc request received"); - meta.request_processor.get_confirmation() + fn get_confirmation_time(&self, meta: Self::Metadata) -> Result { + info!("get_confirmation_time rpc request received"); + meta.request_processor.get_confirmation_time() } fn get_last_id(&self, meta: Self::Metadata) -> Result { info!("get_last_id rpc request received"); @@ -329,8 +329,8 @@ impl JsonRpcRequestProcessor { let val = self.bank.get_balance(&pubkey); Ok(val) } - fn get_confirmation(&self) -> Result { - Ok(self.bank.confirmation()) + fn get_confirmation_time(&self) -> Result { + Ok(self.bank.confirmation_time()) } fn get_last_id(&self) -> Result { let id = self.bank.last_id(); @@ -616,7 +616,7 @@ mod tests { let bob_pubkey = Keypair::new().pubkey(); let (io, meta, _last_id, _alice_keypair) = start_rpc_handler_with_tx(bob_pubkey); - let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"getConfirmation"}}"#); + let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"getConfirmationTime"}}"#); let res = io.handle_request_sync(&req, meta); let expected = format!(r#"{{"jsonrpc":"2.0","result":18446744073709551615,"id":1}}"#); let expected: Response = diff --git a/src/rpc_request.rs b/src/rpc_request.rs index 8f10d909b3..94987e7eae 100644 --- a/src/rpc_request.rs +++ b/src/rpc_request.rs @@ -44,7 +44,7 @@ pub enum RpcRequest { ConfirmTransaction, GetAccountInfo, GetBalance, - GetConfirmation, + GetConfirmationTime, GetLastId, GetSignatureStatus, GetTransactionCount, @@ -89,7 +89,7 @@ impl RpcRequest { RpcRequest::ConfirmTransaction => "confirmTransaction", RpcRequest::GetAccountInfo => "getAccountInfo", RpcRequest::GetBalance => "getBalance", - RpcRequest::GetConfirmation => "getConfirmation", + RpcRequest::GetConfirmationTime => "getConfirmationTime", RpcRequest::GetLastId => "getLastId", RpcRequest::GetSignatureStatus => "getSignatureStatus", RpcRequest::GetTransactionCount => "getTransactionCount", @@ -166,9 +166,9 @@ mod tests { ); assert_eq!(request["method"], "getBalance"); - let test_request = RpcRequest::GetConfirmation; + let test_request = RpcRequest::GetConfirmationTime; let request = test_request.build_request_json(1, None); - assert_eq!(request["method"], "getConfirmation"); + assert_eq!(request["method"], "getConfirmationTime"); assert_eq!(request["params"], json!(null)); let test_request = RpcRequest::GetLastId; diff --git a/src/thin_client.rs b/src/thin_client.rs index 2d95475b4a..a1956b0b9f 100644 --- a/src/thin_client.rs +++ b/src/thin_client.rs @@ -187,20 +187,20 @@ impl ThinClient { .ok_or_else(|| io::Error::new(io::ErrorKind::Other, "AccountNotFound")) } - /// Request the confirmation from the leader node - pub fn get_confirmation(&mut self) -> usize { - trace!("get_confirmation"); + /// Request the confirmation time from the leader node + pub fn get_confirmation_time(&mut self) -> usize { + trace!("get_confirmation_time"); let mut done = false; while !done { - debug!("get_confirmation send_to {}", &self.rpc_addr); - let resp = RpcRequest::GetConfirmation.make_rpc_request(&self.rpc_client, 1, None); + debug!("get_confirmation_time send_to {}", &self.rpc_addr); + let resp = RpcRequest::GetConfirmationTime.make_rpc_request(&self.rpc_client, 1, None); if let Ok(value) = resp { done = true; let confirmation = value.as_u64().unwrap() as usize; self.confirmation = Some(confirmation); } else { - debug!("thin_client get_confirmation error: {:?}", resp); + debug!("thin_client get_confirmation_time error: {:?}", resp); } } self.confirmation.expect("some confirmation") @@ -477,7 +477,7 @@ mod tests { let mut client = ThinClient::new(leader_data.rpc, leader_data.tpu, transactions_socket); let transaction_count = client.transaction_count(); assert_eq!(transaction_count, 0); - let confirmation = client.get_confirmation(); + let confirmation = client.get_confirmation_time(); assert_eq!(confirmation, 18446744073709551615); let last_id = client.get_last_id(); let signature = client diff --git a/tests/multinode.rs b/tests/multinode.rs index b3c28278ba..a2ebb7d4a1 100644 --- a/tests/multinode.rs +++ b/tests/multinode.rs @@ -714,7 +714,7 @@ fn test_multi_node_dynamic_network() { let mut validators: Vec<_> = t2.into_iter().map(|t| t.join().unwrap()).collect(); let mut client = mk_client(&leader_data); - let mut last_confirmation = client.get_confirmation(); + let mut last_confirmation = client.get_confirmation_time(); info!("Last confirmation {}", last_confirmation); let start = Instant::now(); let mut consecutive_success = 0; @@ -738,17 +738,17 @@ fn test_multi_node_dynamic_network() { assert!(e.is_ok(), "err: {:?}", e); let now = Instant::now(); - let mut confirmation = client.get_confirmation(); + let mut confirmation = client.get_confirmation_time(); // Need this to make sure the confirmation is updated // (i.e. the node is not returning stale value) while last_confirmation == confirmation { - confirmation = client.get_confirmation(); + confirmation = client.get_confirmation_time(); } while duration_as_ms(&now.elapsed()) < confirmation as u64 { sleep(Duration::from_millis(100)); - confirmation = client.get_confirmation() + confirmation = client.get_confirmation_time() } last_confirmation = confirmation;