feat: return bank/block info with block-related results (#6716)

This commit is contained in:
Sunny Gleason
2019-11-12 14:49:41 -05:00
committed by GitHub
parent 2688ae614c
commit 5903339c17
10 changed files with 262 additions and 134 deletions

View File

@@ -4,6 +4,7 @@
//! unstable and may change in future releases.
use crate::rpc_client::RpcClient;
use crate::rpc_request::Response;
use bincode::{serialize_into, serialized_size};
use log::*;
use solana_sdk::{
@@ -383,7 +384,11 @@ impl SyncClient for ThinClient {
}
fn get_account(&self, pubkey: &Pubkey) -> TransportResult<Option<Account>> {
Ok(self.rpc_client().get_account(pubkey).ok())
let account = self.rpc_client().get_account(pubkey);
match account {
Ok(value) => Ok(Some(value)),
Err(_) => Ok(None),
}
}
fn get_account_with_commitment(
@@ -393,13 +398,12 @@ impl SyncClient for ThinClient {
) -> TransportResult<Option<Account>> {
Ok(self
.rpc_client()
.get_account_with_commitment(pubkey, commitment_config)
.ok())
.get_account_with_commitment(pubkey, commitment_config)?
.value)
}
fn get_balance(&self, pubkey: &Pubkey) -> TransportResult<u64> {
let balance = self.rpc_client().get_balance(pubkey)?;
Ok(balance)
Ok(self.rpc_client().get_balance(pubkey)?)
}
fn get_balance_with_commitment(
@@ -410,7 +414,7 @@ impl SyncClient for ThinClient {
let balance = self
.rpc_client()
.get_balance_with_commitment(pubkey, commitment_config)?;
Ok(balance)
Ok(balance.value)
}
fn get_recent_blockhash(&self) -> TransportResult<(Hash, FeeCalculator)> {
@@ -426,9 +430,9 @@ impl SyncClient for ThinClient {
let recent_blockhash =
self.rpc_clients[index].get_recent_blockhash_with_commitment(commitment_config);
match recent_blockhash {
Ok(recent_blockhash) => {
Ok(Response { value, .. }) => {
self.optimizer.report(index, duration_as_ms(&now.elapsed()));
Ok(recent_blockhash)
Ok(value)
}
Err(e) => {
self.optimizer.report(index, std::u64::MAX);