Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add get_account to BenchTpsClient #26068

Merged
merged 2 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bench-tps/src/bench_tps_client.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use {
solana_client::{client_error::ClientError, tpu_client::TpuSenderError},
solana_sdk::{
commitment_config::CommitmentConfig, epoch_info::EpochInfo, hash::Hash, message::Message,
pubkey::Pubkey, signature::Signature, transaction::Transaction, transport::TransportError,
account::Account, commitment_config::CommitmentConfig, epoch_info::EpochInfo, hash::Hash,
message::Message, pubkey::Pubkey, signature::Signature, transaction::Transaction,
transport::TransportError,
},
thiserror::Error,
};
Expand Down Expand Up @@ -79,6 +80,9 @@ pub trait BenchTpsClient {
lamports: u64,
recent_blockhash: &Hash,
) -> Result<Signature>;

/// Returns all information associated with the account of the provided pubkey
fn get_account(&self, pubkey: &Pubkey) -> Result<Account>;
}

mod bank_client;
Expand Down
11 changes: 11 additions & 0 deletions bench-tps/src/bench_tps_client/bank_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use {
crate::bench_tps_client::{BenchTpsClient, BenchTpsError, Result},
solana_runtime::bank_client::BankClient,
solana_sdk::{
account::Account,
client::{AsyncClient, SyncClient},
commitment_config::CommitmentConfig,
epoch_info::EpochInfo,
Expand Down Expand Up @@ -82,4 +83,14 @@ impl BenchTpsClient for BankClient {
// BankClient doesn't support airdrops
Err(BenchTpsError::AirdropFailure)
}

fn get_account(&self, pubkey: &Pubkey) -> Result<Account> {
SyncClient::get_account(self, pubkey)
.map_err(|err| err.into())
.and_then(|account| {
account.ok_or_else(|| {
BenchTpsError::Custom(format!("AccountNotFound: pubkey={}", pubkey))
})
})
}
}
8 changes: 6 additions & 2 deletions bench-tps/src/bench_tps_client/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use {
crate::bench_tps_client::{BenchTpsClient, Result},
solana_client::rpc_client::RpcClient,
solana_sdk::{
commitment_config::CommitmentConfig, epoch_info::EpochInfo, hash::Hash, message::Message,
pubkey::Pubkey, signature::Signature, transaction::Transaction,
account::Account, commitment_config::CommitmentConfig, epoch_info::EpochInfo, hash::Hash,
message::Message, pubkey::Pubkey, signature::Signature, transaction::Transaction,
},
};

Expand Down Expand Up @@ -80,4 +80,8 @@ impl BenchTpsClient for RpcClient {
RpcClient::request_airdrop_with_blockhash(self, pubkey, lamports, recent_blockhash)
.map_err(|err| err.into())
}

fn get_account(&self, pubkey: &Pubkey) -> Result<Account> {
RpcClient::get_account(self, pubkey).map_err(|err| err.into())
}
}
7 changes: 7 additions & 0 deletions bench-tps/src/bench_tps_client/thin_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use {
crate::bench_tps_client::{BenchTpsClient, Result},
solana_client::thin_client::ThinClient,
solana_sdk::{
account::Account,
client::{AsyncClient, Client, SyncClient},
commitment_config::CommitmentConfig,
epoch_info::EpochInfo,
Expand Down Expand Up @@ -83,4 +84,10 @@ impl BenchTpsClient for ThinClient {
.request_airdrop_with_blockhash(pubkey, lamports, recent_blockhash)
.map_err(|err| err.into())
}

fn get_account(&self, pubkey: &Pubkey) -> Result<Account> {
self.rpc_client()
.get_account(pubkey)
.map_err(|err| err.into())
}
}
10 changes: 8 additions & 2 deletions bench-tps/src/bench_tps_client/tpu_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use {
crate::bench_tps_client::{BenchTpsClient, Result},
solana_client::tpu_client::TpuClient,
solana_sdk::{
commitment_config::CommitmentConfig, epoch_info::EpochInfo, hash::Hash, message::Message,
pubkey::Pubkey, signature::Signature, transaction::Transaction,
account::Account, commitment_config::CommitmentConfig, epoch_info::EpochInfo, hash::Hash,
message::Message, pubkey::Pubkey, signature::Signature, transaction::Transaction,
},
};

Expand Down Expand Up @@ -96,4 +96,10 @@ impl BenchTpsClient for TpuClient {
.request_airdrop_with_blockhash(pubkey, lamports, recent_blockhash)
.map_err(|err| err.into())
}

fn get_account(&self, pubkey: &Pubkey) -> Result<Account> {
self.rpc_client()
.get_account(pubkey)
.map_err(|err| err.into())
}
}