Skip to content

Commit 8c2b79c

Browse files
Optimize async closure patterns based on GitHub feedback
- Remove unnecessary outer clone in send_transaction_with_config - Move to_vec() calls inside closures to reduce allocations - Maintain intermediate pubkey variable for optimal Copy type handling - All optimizations preserve async move lifetime requirements Co-Authored-By: Ali <[email protected]>
1 parent 49ab4d0 commit 8c2b79c

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/agent/utils/rpc_multi_client.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ impl RpcMultiClient {
258258
&self,
259259
transaction: &Transaction,
260260
) -> anyhow::Result<Signature> {
261-
let transaction = transaction.clone();
262261
self.retry_with_round_robin("sendTransactionWithConfig", |index| {
263262
let client = &self.rpc_clients[index];
264263
let transaction = transaction.clone();
@@ -282,10 +281,9 @@ impl RpcMultiClient {
282281
&self,
283282
signatures_contiguous: &mut [Signature],
284283
) -> anyhow::Result<Vec<Option<TransactionStatus>>> {
285-
let signatures: Vec<Signature> = signatures_contiguous.to_vec();
286284
self.retry_with_round_robin("getSignatureStatuses", |index| {
287285
let client = &self.rpc_clients[index];
288-
let signatures = signatures.clone();
286+
let signatures = signatures_contiguous.to_vec();
289287
Box::pin(async move {
290288
client
291289
.get_signature_statuses(&signatures)
@@ -301,10 +299,9 @@ impl RpcMultiClient {
301299
&self,
302300
price_accounts: &[Pubkey],
303301
) -> anyhow::Result<Vec<RpcPrioritizationFee>> {
304-
let price_accounts = price_accounts.to_vec();
305302
self.retry_with_round_robin("getRecentPrioritizationFees", |index| {
306303
let client = &self.rpc_clients[index];
307-
let price_accounts = price_accounts.clone();
304+
let price_accounts = price_accounts.to_vec();
308305
Box::pin(async move {
309306
client
310307
.get_recent_prioritization_fees(&price_accounts)

0 commit comments

Comments
 (0)