block_hash => blockhash

This commit is contained in:
Michael Vines
2019-03-02 10:25:16 -08:00
committed by Greg Fitzgerald
parent 0f1582c196
commit a94880574b
55 changed files with 591 additions and 597 deletions

View File

@ -57,8 +57,8 @@ impl JsonRpcRequestProcessor {
Ok(val)
}
fn get_recent_block_hash(&self) -> Result<String> {
let id = self.bank()?.last_block_hash();
fn get_recent_blockhash(&self) -> Result<String> {
let id = self.bank()?.last_blockhash();
Ok(bs58::encode(id).into_string())
}
@ -72,8 +72,8 @@ impl JsonRpcRequestProcessor {
Ok(self.bank()?.transaction_count() as u64)
}
fn get_storage_block_hash(&self) -> Result<String> {
let hash = self.storage_state.get_storage_block_hash();
fn get_storage_blockhash(&self) -> Result<String> {
let hash = self.storage_state.get_storage_blockhash();
Ok(bs58::encode(hash).into_string())
}
@ -155,8 +155,8 @@ pub trait RpcSol {
#[rpc(meta, name = "getBalance")]
fn get_balance(&self, _: Self::Metadata, _: String) -> Result<u64>;
#[rpc(meta, name = "getRecentBlockHash")]
fn get_recent_block_hash(&self, _: Self::Metadata) -> Result<String>;
#[rpc(meta, name = "getRecentBlockhash")]
fn get_recent_blockhash(&self, _: Self::Metadata) -> Result<String>;
#[rpc(meta, name = "getSignatureStatus")]
fn get_signature_status(&self, _: Self::Metadata, _: String) -> Result<RpcSignatureStatus>;
@ -170,8 +170,8 @@ pub trait RpcSol {
#[rpc(meta, name = "sendTransaction")]
fn send_transaction(&self, _: Self::Metadata, _: Vec<u8>) -> Result<String>;
#[rpc(meta, name = "getStorageBlockHash")]
fn get_storage_block_hash(&self, _: Self::Metadata) -> Result<String>;
#[rpc(meta, name = "getStorageBlockhash")]
fn get_storage_blockhash(&self, _: Self::Metadata) -> Result<String>;
#[rpc(meta, name = "getStorageEntryHeight")]
fn get_storage_entry_height(&self, _: Self::Metadata) -> Result<u64>;
@ -209,12 +209,12 @@ impl RpcSol for RpcSolImpl {
meta.request_processor.read().unwrap().get_balance(pubkey)
}
fn get_recent_block_hash(&self, meta: Self::Metadata) -> Result<String> {
info!("get_recent_block_hash rpc request received");
fn get_recent_blockhash(&self, meta: Self::Metadata) -> Result<String> {
info!("get_recent_blockhash rpc request received");
meta.request_processor
.read()
.unwrap()
.get_recent_block_hash()
.get_recent_blockhash()
}
fn get_signature_status(&self, meta: Self::Metadata, id: String) -> Result<RpcSignatureStatus> {
@ -258,19 +258,17 @@ impl RpcSol for RpcSolImpl {
trace!("request_airdrop id={} tokens={}", id, tokens);
let pubkey = verify_pubkey(id)?;
let block_hash = meta
let blockhash = meta
.request_processor
.read()
.unwrap()
.bank()?
.last_block_hash();
let transaction =
request_airdrop_transaction(&meta.drone_addr, &pubkey, tokens, block_hash).map_err(
|err| {
info!("request_airdrop_transaction failed: {:?}", err);
Error::internal_error()
},
)?;;
.last_blockhash();
let transaction = request_airdrop_transaction(&meta.drone_addr, &pubkey, tokens, blockhash)
.map_err(|err| {
info!("request_airdrop_transaction failed: {:?}", err);
Error::internal_error()
})?;;
let data = serialize(&transaction).map_err(|err| {
info!("request_airdrop: serialize error: {:?}", err);
@ -338,11 +336,11 @@ impl RpcSol for RpcSolImpl {
Ok(signature)
}
fn get_storage_block_hash(&self, meta: Self::Metadata) -> Result<String> {
fn get_storage_blockhash(&self, meta: Self::Metadata) -> Result<String> {
meta.request_processor
.read()
.unwrap()
.get_storage_block_hash()
.get_storage_blockhash()
}
fn get_storage_entry_height(&self, meta: Self::Metadata) -> Result<u64> {
@ -380,8 +378,8 @@ mod tests {
let (genesis_block, alice) = GenesisBlock::new(10_000);
let bank = Arc::new(Bank::new(&genesis_block));
let block_hash = bank.last_block_hash();
let tx = SystemTransaction::new_move(&alice, pubkey, 20, block_hash, 0);
let blockhash = bank.last_blockhash();
let tx = SystemTransaction::new_move(&alice, pubkey, 20, blockhash, 0);
bank.process_transaction(&tx).expect("process transaction");
let request_processor = Arc::new(RwLock::new(JsonRpcRequestProcessor::new(
@ -405,7 +403,7 @@ mod tests {
drone_addr,
rpc_addr,
};
(io, meta, block_hash, alice)
(io, meta, blockhash, alice)
}
#[test]
@ -416,8 +414,8 @@ mod tests {
let mut request_processor = JsonRpcRequestProcessor::new(StorageState::default());
request_processor.set_bank(&bank);
thread::spawn(move || {
let block_hash = bank.last_block_hash();
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, block_hash, 0);
let blockhash = bank.last_blockhash();
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, blockhash, 0);
bank.process_transaction(&tx).expect("process transaction");
})
.join()
@ -428,7 +426,7 @@ mod tests {
#[test]
fn test_rpc_get_balance() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, _block_hash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let (io, meta, _blockhash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getBalance","params":["{}"]}}"#,
@ -446,7 +444,7 @@ mod tests {
#[test]
fn test_rpc_get_tx_count() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, _block_hash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let (io, meta, _blockhash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"getTransactionCount"}}"#);
let res = io.handle_request_sync(&req, meta);
@ -461,7 +459,7 @@ mod tests {
#[test]
fn test_rpc_get_account_info() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, _block_hash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let (io, meta, _blockhash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getAccountInfo","params":["{}"]}}"#,
@ -488,8 +486,8 @@ mod tests {
#[test]
fn test_rpc_confirm_tx() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, block_hash, alice) = start_rpc_handler_with_tx(bob_pubkey);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, block_hash, 0);
let (io, meta, blockhash, alice) = start_rpc_handler_with_tx(bob_pubkey);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, blockhash, 0);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"confirmTransaction","params":["{}"]}}"#,
@ -507,8 +505,8 @@ mod tests {
#[test]
fn test_rpc_get_signature_status() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, block_hash, alice) = start_rpc_handler_with_tx(bob_pubkey);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, block_hash, 0);
let (io, meta, blockhash, alice) = start_rpc_handler_with_tx(bob_pubkey);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, blockhash, 0);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
@ -523,7 +521,7 @@ mod tests {
assert_eq!(expected, result);
// Test getSignatureStatus request on unprocessed tx
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 10, block_hash, 0);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 10, blockhash, 0);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
tx.signatures[0]
@ -538,13 +536,13 @@ mod tests {
}
#[test]
fn test_rpc_get_recent_block_hash() {
fn test_rpc_get_recent_blockhash() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, block_hash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let (io, meta, blockhash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"getRecentBlockHash"}}"#);
let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"getRecentBlockhash"}}"#);
let res = io.handle_request_sync(&req, meta);
let expected = format!(r#"{{"jsonrpc":"2.0","result":"{}","id":1}}"#, block_hash);
let expected = format!(r#"{{"jsonrpc":"2.0","result":"{}","id":1}}"#, blockhash);
let expected: Response =
serde_json::from_str(&expected).expect("expected response deserialization");
let result: Response = serde_json::from_str(&res.expect("actual response"))
@ -555,7 +553,7 @@ mod tests {
#[test]
fn test_rpc_fail_request_airdrop() {
let bob_pubkey = Keypair::new().pubkey();
let (io, meta, _block_hash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
let (io, meta, _blockhash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
// Expect internal error because no leader is running
let req = format!(