diff --git a/tpu-client/src/tpu_client.rs b/tpu-client/src/tpu_client.rs index 9283af67ecdf09..31ce9c9c8a19a0 100644 --- a/tpu-client/src/tpu_client.rs +++ b/tpu-client/src/tpu_client.rs @@ -1,6 +1,7 @@ pub use crate::nonblocking::tpu_client::TpuSenderError; use { crate::nonblocking::tpu_client::TpuClient as NonblockingTpuClient, + log::*, rayon::iter::{IntoParallelIterator, ParallelIterator}, solana_connection_cache::{ client_connection::ClientConnection, @@ -10,10 +11,9 @@ use { }, solana_rpc_client::rpc_client::RpcClient, solana_sdk::{ - client::AsyncClient, clock::{Slot, MAX_PROCESSING_AGE}, signature::Signature, - transaction::{Transaction, VersionedTransaction}, + transaction::Transaction, transport::Result as TransportResult, }, std::{ @@ -107,23 +107,23 @@ where /// Serialize and send transaction to the current and upcoming leader TPUs according to fanout /// size - /// Attempts to send and confirm tx "tries" times - /// Waits for signature confirmation before returning - /// Returns the transaction signature + /// Attempt to send and confirm tx "attempts" times + /// Wait for signature confirmation before returning + /// Return the transaction signature pub fn send_and_confirm_transaction_with_retries( &self, keypairs: &T, transaction: &mut Transaction, - tries: usize, + attempts: usize, pending_confirmations: usize, ) -> TransportResult { - for x in 0..tries { + for attempt in 0..attempts { let now = Instant::now(); let mut num_confirmed = 0; let mut wait_time = MAX_PROCESSING_AGE; // resend the same transaction until the transaction has no chance of succeeding let wire_transaction = - bincode::serialize(&transaction).expect("transaction serialization failed"); + bincode::serialize(&transaction).expect("should serialize transaction"); while now.elapsed().as_secs() < wait_time as u64 { let leaders = self @@ -154,7 +154,7 @@ where ); } } - log::info!("{x} tries failed transfer"); + info!("{attempt} tries failed transfer"); let blockhash = self.rpc_client().get_latest_blockhash()?; transaction.sign(keypairs, blockhash); } @@ -267,35 +267,6 @@ where } } -impl AsyncClient for TpuClient -where - P: ConnectionPool, - M: ConnectionManager, - C: NewConnectionConfig, -{ - fn async_send_versioned_transaction( - &self, - transaction: VersionedTransaction, - ) -> TransportResult { - let wire_transaction = - bincode::serialize(&transaction).expect("serialize Transaction in send_batch"); - self.send_wire_transaction(wire_transaction); - Ok(transaction.signatures[0]) - } - - fn async_send_versioned_transaction_batch( - &self, - batch: Vec, - ) -> TransportResult<()> { - let buffers = batch - .into_par_iter() - .map(|tx| bincode::serialize(&tx).expect("serialize Transaction in send_batch")) - .collect::>(); - self.try_send_wire_transaction_batch(buffers)?; - Ok(()) - } -} - // 48 chosen because it's unlikely that 12 leaders in a row will miss their slots const MAX_SLOT_SKIP_DISTANCE: u64 = 48;