2022-04-11 12:45:40 -07:00
|
|
|
use {
|
2022-08-24 09:47:02 -07:00
|
|
|
solana_rpc_client_api::client_error::Error as ClientError,
|
2022-04-11 12:45:40 -07:00
|
|
|
solana_sdk::{
|
2022-06-21 10:25:52 -07:00
|
|
|
account::Account, commitment_config::CommitmentConfig, epoch_info::EpochInfo, hash::Hash,
|
|
|
|
message::Message, pubkey::Pubkey, signature::Signature, transaction::Transaction,
|
|
|
|
transport::TransportError,
|
2022-04-11 12:45:40 -07:00
|
|
|
},
|
2022-08-24 09:47:02 -07:00
|
|
|
solana_tpu_client::tpu_client::TpuSenderError,
|
2022-04-11 12:45:40 -07:00
|
|
|
thiserror::Error,
|
|
|
|
};
|
|
|
|
|
|
|
|
#[derive(Error, Debug)]
|
|
|
|
pub enum BenchTpsError {
|
|
|
|
#[error("Airdrop failure")]
|
|
|
|
AirdropFailure,
|
|
|
|
#[error("IO error: {0:?}")]
|
|
|
|
IoError(#[from] std::io::Error),
|
|
|
|
#[error("Client error: {0:?}")]
|
|
|
|
ClientError(#[from] ClientError),
|
|
|
|
#[error("TpuClient error: {0:?}")]
|
|
|
|
TpuSenderError(#[from] TpuSenderError),
|
|
|
|
#[error("Transport error: {0:?}")]
|
|
|
|
TransportError(#[from] TransportError),
|
|
|
|
#[error("Custom error: {0}")]
|
|
|
|
Custom(String),
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) type Result<T> = std::result::Result<T, BenchTpsError>;
|
|
|
|
|
|
|
|
pub trait BenchTpsClient {
|
|
|
|
/// Send a signed transaction without confirmation
|
|
|
|
fn send_transaction(&self, transaction: Transaction) -> Result<Signature>;
|
|
|
|
|
|
|
|
/// Send a batch of signed transactions without confirmation.
|
|
|
|
fn send_batch(&self, transactions: Vec<Transaction>) -> Result<()>;
|
|
|
|
|
|
|
|
/// Get latest blockhash
|
|
|
|
fn get_latest_blockhash(&self) -> Result<Hash>;
|
|
|
|
|
|
|
|
/// Get latest blockhash and its last valid block height, using explicit commitment
|
|
|
|
fn get_latest_blockhash_with_commitment(
|
|
|
|
&self,
|
|
|
|
commitment_config: CommitmentConfig,
|
|
|
|
) -> Result<(Hash, u64)>;
|
|
|
|
|
|
|
|
/// Get transaction count
|
|
|
|
fn get_transaction_count(&self) -> Result<u64>;
|
|
|
|
|
|
|
|
/// Get transaction count, using explicit commitment
|
|
|
|
fn get_transaction_count_with_commitment(
|
|
|
|
&self,
|
|
|
|
commitment_config: CommitmentConfig,
|
|
|
|
) -> Result<u64>;
|
|
|
|
|
|
|
|
/// Get epoch info
|
|
|
|
fn get_epoch_info(&self) -> Result<EpochInfo>;
|
|
|
|
|
|
|
|
/// Get account balance
|
|
|
|
fn get_balance(&self, pubkey: &Pubkey) -> Result<u64>;
|
|
|
|
|
|
|
|
/// Get account balance, using explicit commitment
|
|
|
|
fn get_balance_with_commitment(
|
|
|
|
&self,
|
|
|
|
pubkey: &Pubkey,
|
|
|
|
commitment_config: CommitmentConfig,
|
|
|
|
) -> Result<u64>;
|
|
|
|
|
|
|
|
/// Calculate the fee for a `Message`
|
|
|
|
fn get_fee_for_message(&self, message: &Message) -> Result<u64>;
|
|
|
|
|
|
|
|
/// Get the rent-exempt minimum for an account
|
|
|
|
fn get_minimum_balance_for_rent_exemption(&self, data_len: usize) -> Result<u64>;
|
|
|
|
|
|
|
|
/// Return the address of client
|
|
|
|
fn addr(&self) -> String;
|
|
|
|
|
|
|
|
/// Request, submit, and confirm an airdrop transaction
|
|
|
|
fn request_airdrop_with_blockhash(
|
|
|
|
&self,
|
|
|
|
pubkey: &Pubkey,
|
|
|
|
lamports: u64,
|
|
|
|
recent_blockhash: &Hash,
|
|
|
|
) -> Result<Signature>;
|
2022-06-21 10:25:52 -07:00
|
|
|
|
|
|
|
/// Returns all information associated with the account of the provided pubkey
|
|
|
|
fn get_account(&self, pubkey: &Pubkey) -> Result<Account>;
|
2022-08-18 01:17:32 -07:00
|
|
|
|
|
|
|
/// Returns all information associated with the account of the provided pubkey, using explicit commitment
|
|
|
|
fn get_account_with_commitment(
|
|
|
|
&self,
|
|
|
|
pubkey: &Pubkey,
|
|
|
|
commitment_config: CommitmentConfig,
|
|
|
|
) -> Result<Account>;
|
2022-04-11 12:45:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
mod bank_client;
|
2022-04-13 12:11:34 -07:00
|
|
|
mod rpc_client;
|
2022-04-11 12:45:40 -07:00
|
|
|
mod thin_client;
|
2022-04-12 08:43:29 -07:00
|
|
|
mod tpu_client;
|