31
31
tokio:: { sync:: RwLock , task:: JoinHandle , time:: Instant } ,
32
32
} ;
33
33
34
- const BLOCKHASH_REFRESH_RATE : Duration = Duration :: from_secs ( 10 ) ;
34
+ const BLOCKHASH_REFRESH_RATE : Duration = Duration :: from_secs ( 5 ) ;
35
35
const TPU_RESEND_REFRESH_RATE : Duration = Duration :: from_secs ( 2 ) ;
36
36
const SEND_INTERVAL : Duration = Duration :: from_millis ( 10 ) ;
37
37
type QuicTpuClient = TpuClient < QuicPool , QuicConnectionManager , QuicConfig > ;
@@ -326,21 +326,20 @@ async fn confirm_transactions_till_block_height_and_resend_unexpired_transaction
326
326
) ;
327
327
}
328
328
329
+ if let Some ( progress_bar) = progress_bar {
330
+ let progress = progress_from_context_and_block_height ( context, max_valid_block_height) ;
331
+ progress. set_message_for_confirmed_transactions (
332
+ progress_bar,
333
+ "Checking transaction status..." ,
334
+ ) ;
335
+ }
336
+
329
337
// wait till all transactions are confirmed or we have surpassed max processing age for the last sent transaction
330
338
while !unconfirmed_transaction_map. is_empty ( )
331
339
&& current_block_height. load ( Ordering :: Relaxed ) <= max_valid_block_height
332
340
{
333
341
let block_height = current_block_height. load ( Ordering :: Relaxed ) ;
334
342
335
- if let Some ( progress_bar) = progress_bar {
336
- let progress =
337
- progress_from_context_and_block_height ( context, max_valid_block_height) ;
338
- progress. set_message_for_confirmed_transactions (
339
- progress_bar,
340
- "Checking transaction status..." ,
341
- ) ;
342
- }
343
-
344
343
if let Some ( tpu_client) = tpu_client {
345
344
let instant = Instant :: now ( ) ;
346
345
// retry sending transaction only over TPU port
@@ -349,10 +348,29 @@ async fn confirm_transactions_till_block_height_and_resend_unexpired_transaction
349
348
. iter ( )
350
349
. filter ( |x| block_height < x. last_valid_block_height )
351
350
. map ( |x| x. serialized_transaction . clone ( ) )
352
- . collect ( ) ;
353
- let _ = tpu_client
354
- . try_send_wire_transaction_batch ( txs_to_resend_over_tpu)
355
- . await ;
351
+ . collect :: < Vec < _ > > ( ) ;
352
+ let num_txs_to_resend = txs_to_resend_over_tpu. len ( ) ;
353
+ // This is a "reasonable" constant for how long it should
354
+ // take to fan the transactions out, taken from
355
+ // `solana_tpu_client::nonblocking::tpu_client::send_wire_transaction_futures`
356
+ const SEND_TIMEOUT_INTERVAL : Duration = Duration :: from_secs ( 5 ) ;
357
+ let message = if tokio:: time:: timeout (
358
+ SEND_TIMEOUT_INTERVAL ,
359
+ tpu_client. try_send_wire_transaction_batch ( txs_to_resend_over_tpu) ,
360
+ )
361
+ . await
362
+ . is_err ( )
363
+ {
364
+ format ! ( "Timed out resending {num_txs_to_resend} transactions..." )
365
+ } else {
366
+ format ! ( "Resent {num_txs_to_resend} transactions..." )
367
+ } ;
368
+
369
+ if let Some ( progress_bar) = progress_bar {
370
+ let progress =
371
+ progress_from_context_and_block_height ( context, max_valid_block_height) ;
372
+ progress. set_message_for_confirmed_transactions ( progress_bar, & message) ;
373
+ }
356
374
357
375
let elapsed = instant. elapsed ( ) ;
358
376
if elapsed < TPU_RESEND_REFRESH_RATE {
@@ -370,14 +388,6 @@ async fn confirm_transactions_till_block_height_and_resend_unexpired_transaction
370
388
max_valid_block_height = max_valid_block_height_in_remaining_transaction;
371
389
}
372
390
}
373
-
374
- if let Some ( progress_bar) = progress_bar {
375
- let progress = progress_from_context_and_block_height ( context, max_valid_block_height) ;
376
- progress. set_message_for_confirmed_transactions (
377
- progress_bar,
378
- "Checking transaction status..." ,
379
- ) ;
380
- }
381
391
}
382
392
}
383
393
0 commit comments