Skip to content

Commit

Permalink
dont clone connection cache. and use try_send_transaction_blocking in…
Browse files Browse the repository at this point in the history
… transfer_with_client
  • Loading branch information
gregcusack committed Apr 22, 2024
1 parent a3056ee commit 9b74bf6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 32 deletions.
4 changes: 2 additions & 2 deletions local-cluster/src/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ impl LocalCluster {
*dest_pubkey
);
client
.try_send_transaction(&tx)
.try_send_transaction_blocking(&tx)
.expect("client transfer should succeed");
client
.rpc_client()
Expand Down Expand Up @@ -763,7 +763,7 @@ impl LocalCluster {
.0,
);
client
.try_send_transaction_blocking(&transaction)
.try_send_transaction(&transaction)
.expect("should fund vote");
client
.rpc_client()
Expand Down
4 changes: 2 additions & 2 deletions tpu-client/src/nonblocking/tpu_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,13 +702,13 @@ where
self.leader_tpu_service.join().await;
}

pub fn get_connection_cache(&self) -> Arc<ConnectionCache<P, M, C>>
pub fn get_connection_cache(&self) -> &Arc<ConnectionCache<P, M, C>>
where
P: ConnectionPool<NewConnectionConfig = C>,
M: ConnectionManager<ConnectionPool = P, NewConnectionConfig = C>,
C: NewConnectionConfig,
{
self.connection_cache.clone()
&self.connection_cache
}

pub fn get_leader_tpu_service(&self) -> &LeaderTpuService {
Expand Down
31 changes: 3 additions & 28 deletions tpu-client/src/tpu_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,37 +112,12 @@ where
.tpu_client
.get_leader_tpu_service()
.leader_tpu_sockets(self.tpu_client.get_fanout_slots());
let cc = self.tpu_client.get_connection_cache();
let cache = self.tpu_client.get_connection_cache();
for tpu_address in &leaders {
let conn = cc.get_connection(tpu_address);
match conn.send_data_async(wire_transaction.clone()) {
Ok(_) => println!("tpuclient send_data success"),
Err(err) => println!("tpuclient send_data failed: {err}"),
}
let conn = cache.get_connection(tpu_address);
conn.send_data_async(wire_transaction.clone())?;
}

// match self.rpc_client().poll_for_signature_confirmation(
// &transaction.signatures[0],
// pending_confirmations,
// ) {
// Ok(confirmed_blocks) => {
// println!("tpuclient confirmed blocks found: {confirmed_blocks}");
// // println!("thinclient num confirmed: {num_confirmed}");
// // num_confirmed = confirmed_blocks;
// if confirmed_blocks >= pending_confirmations {
// println!("tpuclient confirmed blocks >= pending confirmations {confirmed_blocks} > {pending_confirmations}");
// return Ok(transaction.signatures[0]);
// }
// // Since network has seen the transaction, wait longer to receive
// // all pending confirmations. Resending the transaction could result into
// // extra transaction fees
// // wait_time = wait_time.max(
// // MAX_PROCESSING_AGE * pending_confirmations.saturating_sub(num_confirmed),
// // );
// }
// Err(err) => println!("tpuclient error polling for signature confirmation: err: {err}"),
// }

if let Ok(confirmed_blocks) = self
.rpc_client()
.poll_for_signature_confirmation(&transaction.signatures[0], pending_confirmations)
Expand Down

0 comments on commit 9b74bf6

Please sign in to comment.