File tree Expand file tree Collapse file tree 1 file changed +17
-18
lines changed Expand file tree Collapse file tree 1 file changed +17
-18
lines changed Original file line number Diff line number Diff line change @@ -437,32 +437,31 @@ pub(crate) fn wait_for_block<E: ElectrumApi>(electrs: &E, min_height: usize) {
437
437
}
438
438
439
439
pub ( crate ) fn wait_for_tx < E : ElectrumApi > ( electrs : & E , txid : Txid ) {
440
- let mut tx_res = electrs. transaction_get ( & txid) ;
441
- loop {
442
- if tx_res. is_ok ( ) {
443
- break ;
444
- }
445
- tx_res = exponential_backoff_poll ( || {
446
- electrs. ping ( ) . unwrap ( ) ;
447
- Some ( electrs. transaction_get ( & txid) )
448
- } ) ;
440
+ if electrs. transaction_get ( & txid) . is_ok ( ) {
441
+ return ;
449
442
}
443
+
444
+ exponential_backoff_poll ( || {
445
+ electrs. ping ( ) . unwrap ( ) ;
446
+ electrs. transaction_get ( & txid) . ok ( )
447
+ } ) ;
450
448
}
451
449
452
450
pub ( crate ) fn wait_for_outpoint_spend < E : ElectrumApi > ( electrs : & E , outpoint : OutPoint ) {
453
451
let tx = electrs. transaction_get ( & outpoint. txid ) . unwrap ( ) ;
454
452
let txout_script = tx. output . get ( outpoint. vout as usize ) . unwrap ( ) . clone ( ) . script_pubkey ;
455
- let mut is_spent = !electrs. script_get_history ( & txout_script) . unwrap ( ) . is_empty ( ) ;
456
- loop {
457
- if is_spent {
458
- break ;
459
- }
460
453
461
- is_spent = exponential_backoff_poll ( || {
462
- electrs. ping ( ) . unwrap ( ) ;
463
- Some ( !electrs. script_get_history ( & txout_script) . unwrap ( ) . is_empty ( ) )
464
- } ) ;
454
+ let is_spent = !electrs. script_get_history ( & txout_script) . unwrap ( ) . is_empty ( ) ;
455
+ if is_spent {
456
+ return ;
465
457
}
458
+
459
+ exponential_backoff_poll ( || {
460
+ electrs. ping ( ) . unwrap ( ) ;
461
+
462
+ let is_spent = !electrs. script_get_history ( & txout_script) . unwrap ( ) . is_empty ( ) ;
463
+ is_spent. then_some ( ( ) )
464
+ } ) ;
466
465
}
467
466
468
467
pub ( crate ) fn exponential_backoff_poll < T , F > ( mut poll : F ) -> T
You can’t perform that action at this time.
0 commit comments