Add get_confirmed_block_with_encoding() (#9046)

automerge
This commit is contained in:
Michael Vines 2020-03-24 05:05:38 -07:00 committed by GitHub
parent 19dfb87b1f
commit 56dc958116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 6 deletions

View File

@ -4,11 +4,7 @@ use crate::{
mock_rpc_client_request::{MockRpcClientRequest, Mocks},
rpc_client_request::RpcClientRequest,
rpc_request::{RpcError, RpcRequest},
rpc_response::{
Response, RpcAccount, RpcBlockhashFeeCalculator, RpcConfirmedBlock, RpcContactInfo,
RpcEpochInfo, RpcFeeCalculator, RpcFeeRateGovernor, RpcIdentity, RpcKeyedAccount,
RpcLeaderSchedule, RpcResult, RpcTransactionStatus, RpcVersionInfo, RpcVoteAccountStatus,
},
rpc_response::*,
};
use bincode::serialize;
use indicatif::{ProgressBar, ProgressStyle};
@ -190,9 +186,17 @@ impl RpcClient {
}
pub fn get_confirmed_block(&self, slot: Slot) -> ClientResult<RpcConfirmedBlock> {
self.get_confirmed_block_with_encoding(slot, RpcTransactionEncoding::Json)
}
pub fn get_confirmed_block_with_encoding(
&self,
slot: Slot,
encoding: RpcTransactionEncoding,
) -> ClientResult<RpcConfirmedBlock> {
let response = self
.client
.send(&RpcRequest::GetConfirmedBlock, json!([slot]), 0)
.send(&RpcRequest::GetConfirmedBlock, json!([slot, encoding]), 0)
.map_err(|err| err.into_with_command("GetConfirmedBlock"))?;
serde_json::from_value(response)