Rename getConfirmation -> getConfirmationTime

This commit is contained in:
Michael Vines 2018-12-21 08:25:07 -08:00
parent 371cb4f0f3
commit 2c9607d5da
6 changed files with 32 additions and 32 deletions

View File

@ -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() {

View File

@ -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);
}
}

View File

@ -135,8 +135,8 @@ build_rpc_trait! {
#[rpc(meta, name = "getBalance")]
fn get_balance(&self, Self::Metadata, String) -> Result<u64>;
#[rpc(meta, name = "getConfirmation")]
fn get_confirmation(&self, Self::Metadata) -> Result<usize>;
#[rpc(meta, name = "getConfirmationTime")]
fn get_confirmation_time(&self, Self::Metadata) -> Result<usize>;
#[rpc(meta, name = "getLastId")]
fn get_last_id(&self, Self::Metadata) -> Result<String>;
@ -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<usize> {
info!("get_confirmation rpc request received");
meta.request_processor.get_confirmation()
fn get_confirmation_time(&self, meta: Self::Metadata) -> Result<usize> {
info!("get_confirmation_time rpc request received");
meta.request_processor.get_confirmation_time()
}
fn get_last_id(&self, meta: Self::Metadata) -> Result<String> {
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<usize> {
Ok(self.bank.confirmation())
fn get_confirmation_time(&self) -> Result<usize> {
Ok(self.bank.confirmation_time())
}
fn get_last_id(&self) -> Result<String> {
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 =

View File

@ -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;

View File

@ -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

View File

@ -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;