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 @@ -448,32 +448,31 @@ pub(crate) fn wait_for_block<E: ElectrumApi>(electrs: &E, min_height: usize) {
448
448
}
449
449
450
450
pub ( crate ) fn wait_for_tx < E : ElectrumApi > ( electrs : & E , txid : Txid ) {
451
- let mut tx_res = electrs. transaction_get ( & txid) ;
452
- loop {
453
- if tx_res. is_ok ( ) {
454
- break ;
455
- }
456
- tx_res = exponential_backoff_poll ( || {
457
- electrs. ping ( ) . unwrap ( ) ;
458
- Some ( electrs. transaction_get ( & txid) )
459
- } ) ;
451
+ if electrs. transaction_get ( & txid) . is_ok ( ) {
452
+ return ;
460
453
}
454
+
455
+ exponential_backoff_poll ( || {
456
+ electrs. ping ( ) . unwrap ( ) ;
457
+ electrs. transaction_get ( & txid) . ok ( )
458
+ } ) ;
461
459
}
462
460
463
461
pub ( crate ) fn wait_for_outpoint_spend < E : ElectrumApi > ( electrs : & E , outpoint : OutPoint ) {
464
462
let tx = electrs. transaction_get ( & outpoint. txid ) . unwrap ( ) ;
465
463
let txout_script = tx. output . get ( outpoint. vout as usize ) . unwrap ( ) . clone ( ) . script_pubkey ;
466
- let mut is_spent = !electrs. script_get_history ( & txout_script) . unwrap ( ) . is_empty ( ) ;
467
- loop {
468
- if is_spent {
469
- break ;
470
- }
471
464
472
- is_spent = exponential_backoff_poll ( || {
473
- electrs. ping ( ) . unwrap ( ) ;
474
- Some ( !electrs. script_get_history ( & txout_script) . unwrap ( ) . is_empty ( ) )
475
- } ) ;
465
+ let is_spent = !electrs. script_get_history ( & txout_script) . unwrap ( ) . is_empty ( ) ;
466
+ if is_spent {
467
+ return ;
476
468
}
469
+
470
+ exponential_backoff_poll ( || {
471
+ electrs. ping ( ) . unwrap ( ) ;
472
+
473
+ let is_spent = !electrs. script_get_history ( & txout_script) . unwrap ( ) . is_empty ( ) ;
474
+ is_spent. then_some ( ( ) )
475
+ } ) ;
477
476
}
478
477
479
478
pub ( crate ) fn exponential_backoff_poll < T , F > ( mut poll : F ) -> T
You can’t perform that action at this time.
0 commit comments