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) {
448448}
449449
450450pub ( 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 ;
460453 }
454+
455+ exponential_backoff_poll ( || {
456+ electrs. ping ( ) . unwrap ( ) ;
457+ electrs. transaction_get ( & txid) . ok ( )
458+ } ) ;
461459}
462460
463461pub ( crate ) fn wait_for_outpoint_spend < E : ElectrumApi > ( electrs : & E , outpoint : OutPoint ) {
464462 let tx = electrs. transaction_get ( & outpoint. txid ) . unwrap ( ) ;
465463 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- }
471464
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 ;
476468 }
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+ } ) ;
477476}
478477
479478pub ( crate ) fn exponential_backoff_poll < T , F > ( mut poll : F ) -> T
You can’t perform that action at this time.
0 commit comments