Rename get_last_id() to get_recent_block_hash()

This commit is contained in:
Michael Vines
2019-03-02 10:01:13 -08:00
committed by Greg Fitzgerald
parent 4f3e149a98
commit ce1b72809a
11 changed files with 49 additions and 49 deletions

View File

@ -27,7 +27,7 @@ pub fn spend_and_verify_all_nodes(
&funding_keypair,
random_keypair.pubkey(),
1,
client.get_last_id(),
client.get_recent_block_hash(),
0,
);
let sig = client

View File

@ -122,7 +122,7 @@ impl LocalCluster {
lamports: u64,
) -> u64 {
trace!("getting leader last_id");
let last_id = client.get_last_id();
let last_id = client.get_recent_block_hash();
let mut tx =
SystemTransaction::new_account(&source_keypair, *dest_pubkey, lamports, last_id, 0);
info!(
@ -148,7 +148,7 @@ impl LocalCluster {
let mut transaction = VoteTransaction::fund_staking_account(
from_account,
vote_account,
client.get_last_id(),
client.get_recent_block_hash(),
amount,
1,
);

View File

@ -254,7 +254,7 @@ impl Replicator {
match sample_file(&ledger_data_file_encrypted, &sampling_offsets) {
Ok(hash) => {
let last_id = client.get_last_id();
let last_id = client.get_recent_block_hash();
info!("sampled hash: {}", hash);
let mut tx = StorageTransaction::new_mining_proof(
&keypair,
@ -366,7 +366,7 @@ impl Replicator {
let airdrop_amount = 1;
let last_id = client.get_last_id();
let last_id = client.get_recent_block_hash();
match request_airdrop_transaction(
&drone_addr,
&keypair.pubkey(),

View File

@ -57,7 +57,7 @@ impl JsonRpcRequestProcessor {
Ok(val)
}
fn get_last_id(&self) -> Result<String> {
fn get_recent_block_hash(&self) -> Result<String> {
let id = self.bank()?.last_id();
Ok(bs58::encode(id).into_string())
}
@ -156,7 +156,7 @@ pub trait RpcSol {
fn get_balance(&self, _: Self::Metadata, _: String) -> Result<u64>;
#[rpc(meta, name = "getLastId")]
fn get_last_id(&self, _: Self::Metadata) -> Result<String>;
fn get_recent_block_hash(&self, _: Self::Metadata) -> Result<String>;
#[rpc(meta, name = "getSignatureStatus")]
fn get_signature_status(&self, _: Self::Metadata, _: String) -> Result<RpcSignatureStatus>;
@ -209,9 +209,9 @@ impl RpcSol for RpcSolImpl {
meta.request_processor.read().unwrap().get_balance(pubkey)
}
fn get_last_id(&self, meta: Self::Metadata) -> Result<String> {
info!("get_last_id rpc request received");
meta.request_processor.read().unwrap().get_last_id()
fn get_recent_block_hash(&self, meta: Self::Metadata) -> Result<String> {
info!("get_recent_block_hash rpc request received");
meta.request_processor.read().unwrap().get_recent_block_hash()
}
fn get_signature_status(&self, meta: Self::Metadata, id: String) -> Result<RpcSignatureStatus> {
@ -528,7 +528,7 @@ mod tests {
}
#[test]
fn test_rpc_get_last_id() {
fn test_rpc_get_recent_block_hash() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, last_id, _alice) = start_rpc_handler_with_tx(bob_pubkey);

View File

@ -237,7 +237,7 @@ impl StorageStage {
let mut last_id = None;
for _ in 0..10 {
if let Some(new_last_id) = client.try_get_last_id(1) {
if let Some(new_last_id) = client.try_get_recent_block_hash(1) {
last_id = Some(new_last_id);
break;
}

View File

@ -99,7 +99,7 @@ impl ThinClient {
tries: usize,
) -> io::Result<Signature> {
for x in 0..tries {
transaction.sign(&[keypair], self.get_last_id());
transaction.sign(&[keypair], self.get_recent_block_hash());
let mut buf = vec![0; transaction.serialized_size().unwrap() as usize];
let mut wr = std::io::Cursor::new(&mut buf[..]);
serialize_into(&mut wr, &transaction)
@ -217,9 +217,9 @@ impl ThinClient {
/// Request the last Entry ID from the server without blocking.
/// Returns the last_id Hash or None if there was no response from the server.
pub fn try_get_last_id(&mut self, mut num_retries: u64) -> Option<Hash> {
pub fn try_get_recent_block_hash(&mut self, mut num_retries: u64) -> Option<Hash> {
loop {
trace!("try_get_last_id send_to {}", &self.rpc_addr);
trace!("try_get_recent_block_hash send_to {}", &self.rpc_addr);
let response = self
.rpc_client
.make_rpc_request(1, RpcRequest::GetLastId, None);
@ -231,7 +231,7 @@ impl ThinClient {
return Some(Hash::new(&last_id_vec));
}
Err(error) => {
debug!("thin_client get_last_id error: {:?}", error);
debug!("thin_client get_recent_block_hash error: {:?}", error);
num_retries -= 1;
if num_retries == 0 {
return None;
@ -243,10 +243,10 @@ impl ThinClient {
/// Request the last Entry ID from the server. This method blocks
/// until the server sends a response.
pub fn get_last_id(&mut self) -> Hash {
pub fn get_recent_block_hash(&mut self) -> Hash {
loop {
trace!("get_last_id send_to {}", &self.rpc_addr);
if let Some(hash) = self.try_get_last_id(10) {
trace!("get_recent_block_hash send_to {}", &self.rpc_addr);
if let Some(hash) = self.try_get_recent_block_hash(10) {
return hash;
}
}
@ -261,7 +261,7 @@ impl ThinClient {
}
pub fn get_next_last_id_ext(&mut self, previous_last_id: &Hash, func: &Fn()) -> Hash {
loop {
let last_id = self.get_last_id();
let last_id = self.get_recent_block_hash();
if last_id != *previous_last_id {
break last_id;
}
@ -511,7 +511,7 @@ mod tests {
let transaction_count = client.transaction_count();
assert_eq!(transaction_count, 0);
let last_id = client.get_last_id();
let last_id = client.get_recent_block_hash();
info!("test_thin_client last_id: {:?}", last_id);
let signature = client.transfer(500, &alice, bob_pubkey, &last_id).unwrap();
@ -541,13 +541,13 @@ mod tests {
let mut client = mk_client(&leader_data);
let last_id = client.get_last_id();
let last_id = client.get_recent_block_hash();
let tx = SystemTransaction::new_account(&alice, bob_pubkey, 500, last_id, 0);
let _sig = client.transfer_signed(&tx).unwrap();
let last_id = client.get_last_id();
let last_id = client.get_recent_block_hash();
let mut tr2 = SystemTransaction::new_account(&alice, bob_pubkey, 501, last_id, 0);
let mut instruction2 = deserialize(tr2.userdata(0)).unwrap();
@ -578,7 +578,7 @@ mod tests {
// Create the validator account, transfer some tokens to that account
let validator_keypair = Keypair::new();
let last_id = client.get_last_id();
let last_id = client.get_recent_block_hash();
let signature = client
.transfer(500, &alice, validator_keypair.pubkey(), &last_id)
.unwrap();
@ -588,7 +588,7 @@ mod tests {
// Create and register the vote account
let validator_vote_account_keypair = Keypair::new();
let vote_account_id = validator_vote_account_keypair.pubkey();
let last_id = client.get_last_id();
let last_id = client.get_recent_block_hash();
let transaction = VoteTransaction::fund_staking_account(
&validator_keypair,
@ -652,7 +652,7 @@ mod tests {
);
let mut client = mk_client(&leader_data);
let last_id = client.get_last_id();
let last_id = client.get_recent_block_hash();
info!("test_thin_client last_id: {:?}", last_id);
let starting_alice_balance = client.poll_get_balance(&alice.pubkey()).unwrap();