File tree Expand file tree Collapse file tree 1 file changed +21
-10
lines changed
Expand file tree Collapse file tree 1 file changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -341,9 +341,11 @@ impl Client {
341341 self . inner . try_send_batch ( batch. iter ( ) . collect ( ) )
342342 {
343343 retry += 1 ;
344- if retry > 10 {
345- send. send ( CoinResponse :: Error ( format ! ( "electrum::Client::listen_txs() Fail to send bacth request: {:?}" , e) ) . into ( ) ) . expect ( "caller dropped" ) ;
346- }
344+ if retry > 10 && send. send ( CoinResponse :: Error ( format ! ( "electrum::Client::listen_txs() Fail to send bacth request: {:?}" , e) ) . into ( ) ) . is_err ( ) {
345+ // NOTE: caller has dropped the channel
346+ // == Close request
347+ return ;
348+ }
347349 thread:: sleep ( Duration :: from_millis ( 50 ) ) ;
348350 }
349351 }
@@ -429,9 +431,14 @@ impl Client {
429431 txs. push ( tx) ;
430432 }
431433 Response :: Error ( e) => {
432- // TODO: do not unwrap
433- send. send ( CoinResponse :: Error ( e. to_string ( ) ) . into ( ) )
434- . unwrap ( ) ;
434+ if send
435+ . send ( CoinResponse :: Error ( e. to_string ( ) ) . into ( ) )
436+ . is_err ( )
437+ {
438+ // NOTE: caller has dropped the channel
439+ // == Close request
440+ return ;
441+ }
435442 }
436443 _ => { }
437444 }
@@ -455,10 +462,14 @@ impl Client {
455462 }
456463 Ok ( None ) => { }
457464 Err ( e) => {
458- log:: error!( "Client::listen_txs() error receiving response: {e}" ) ;
459- // TODO: do not unwrap
460- send. send ( CoinResponse :: Error ( e. to_string ( ) ) . into ( ) )
461- . unwrap ( ) ;
465+ if send
466+ . send ( CoinResponse :: Error ( e. to_string ( ) ) . into ( ) )
467+ . is_err ( )
468+ {
469+ // NOTE: caller has dropped the channel
470+ // == Close request
471+ return ;
472+ }
462473 }
463474 }
464475 if received {
You can’t perform that action at this time.
0 commit comments