From 03f7f0d18ced50e1a8c9796504399da8ef819b5b Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Thu, 14 Nov 2019 14:14:42 -0700 Subject: [PATCH] Rename getBlock to getConfirmedBlock; remove getBlocksSince (#6961) automerge --- core/src/rpc.rs | 52 ++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/core/src/rpc.rs b/core/src/rpc.rs index fafbafdf5..1d05a4a21 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -17,9 +17,7 @@ use solana_client::rpc_request::{ RpcVoteAccountStatus, }; use solana_drone::drone::request_airdrop_transaction; -use solana_ledger::{ - bank_forks::BankForks, blocktree::Blocktree, rooted_slot_iterator::RootedSlotIterator, -}; +use solana_ledger::{bank_forks::BankForks, blocktree::Blocktree}; use solana_runtime::bank::Bank; use solana_sdk::{ account::Account, @@ -306,18 +304,14 @@ impl JsonRpcRequestProcessor { } } - pub fn get_blocks_since(&self, slot: Slot) -> Result> { - Ok(RootedSlotIterator::new(slot, &self.blocktree) - .map_err(|err| Error::invalid_params(format!("Slot {:?}: {:?}", slot, err)))? - .map(|(slot, _)| slot) - .collect()) - } - - // The `get_block` method is not fully implemented. It currenlty returns a batch of test transaction - // tuples (Transaction, transaction::Result) to demonstrate message format and + // The `get_confirmed_block` method is not fully implemented. It currenlty returns a batch of + // test transaction tuples (Transaction, transaction::Result) to demonstrate message format and // TransactionErrors. Transaction count == slot, and transaction keys are derived // deterministically to allow testers to track the pubkeys across slots. - pub fn get_block(&self, slot: Slot) -> Result, transaction::Result<()>)>> { + pub fn get_confirmed_block( + &self, + slot: Slot, + ) -> Result)>> { Ok(make_test_transactions(slot)) } } @@ -523,15 +517,12 @@ pub trait RpcSol { #[rpc(meta, name = "setLogFilter")] fn set_log_filter(&self, _meta: Self::Metadata, filter: String) -> Result<()>; - #[rpc(meta, name = "getBlocksSince")] - fn get_blocks_since(&self, meta: Self::Metadata, slot: Slot) -> Result>; - - #[rpc(meta, name = "getBlock")] - fn get_block( + #[rpc(meta, name = "getConfirmedBlock")] + fn get_confirmed_block( &self, meta: Self::Metadata, slot: Slot, - ) -> Result, transaction::Result<()>)>>; + ) -> Result)>>; } pub struct RpcSolImpl; @@ -976,26 +967,22 @@ impl RpcSol for RpcSolImpl { Ok(()) } - fn get_blocks_since(&self, meta: Self::Metadata, slot: Slot) -> Result> { - meta.request_processor - .read() - .unwrap() - .get_blocks_since(slot) - } - - fn get_block( + fn get_confirmed_block( &self, meta: Self::Metadata, slot: Slot, - ) -> Result, transaction::Result<()>)>> { - meta.request_processor.read().unwrap().get_block(slot) + ) -> Result)>> { + meta.request_processor + .read() + .unwrap() + .get_confirmed_block(slot) } } -fn make_test_transactions(count: u64) -> Vec<(Vec, transaction::Result<()>)> { +fn make_test_transactions(count: u64) -> Vec<(Transaction, transaction::Result<()>)> { let seed = [42u8; 32]; let keys = GenKeys::new(seed).gen_n_keypairs(count + 1); - let mut transactions: Vec<(Vec, transaction::Result<()>)> = Vec::new(); + let mut transactions: Vec<(Transaction, transaction::Result<()>)> = Vec::new(); for x in 0..count { let tx = system_transaction::transfer( &keys[x as usize], @@ -1003,7 +990,6 @@ fn make_test_transactions(count: u64) -> Vec<(Vec, transaction::Result<()>)> 123, Hash::default(), ); - let wire_transaction = serialize(&tx).unwrap(); let status = if x % 3 == 0 { Ok(()) } else if x % 3 == 1 { @@ -1017,7 +1003,7 @@ fn make_test_transactions(count: u64) -> Vec<(Vec, transaction::Result<()>)> InstructionError::CustomError(3), )) }; - transactions.push((wire_transaction, status)) + transactions.push((tx, status)) } transactions }