@@ -763,7 +763,7 @@ func (b *BatchCaretaker) stateStep(currentState BatchState) (BatchState, error)
763763 b .cfg .Batch .GenesisPacket .ChainFees = chainFees
764764
765765 log .Infof ("BatchCaretaker(%x): GenesisPacket absolute fee: " +
766- "%d sats" , chainFees )
766+ "%d sats" , b . batchKey [:], chainFees )
767767 log .Infof ("BatchCaretaker(%x): GenesisPacket finalized" ,
768768 b .batchKey [:])
769769 log .Tracef ("GenesisPacket: %v" , spew .Sdump (signedPkt ))
@@ -871,32 +871,43 @@ func (b *BatchCaretaker) stateStep(currentState BatchState) (BatchState, error)
871871 defer confCancel ()
872872 defer b .Wg .Done ()
873873
874- var confEvent * chainntnfs.TxConfirmation
875- select {
876- case confEvent = <- confNtfn .Confirmed :
877- log .Debugf ("Got chain confirmation: %v" ,
878- confEvent .Tx .TxHash ())
879-
880- case err := <- errChan :
881- b .cfg .ErrChan <- fmt .Errorf ("error getting " +
882- "confirmation: %w" , err )
883- return
874+ var (
875+ confEvent * chainntnfs.TxConfirmation
876+ confRecv bool
877+ )
884878
885- case <- confCtx .Done ():
886- log .Debugf ("Skipping TX confirmation, context " +
887- "done" )
879+ for ! confRecv {
880+ select {
881+ case confEvent = <- confNtfn .Confirmed :
882+ log .Debugf ("Got chain confirmation: %v" ,
883+ confEvent .Tx .TxHash ())
884+ confRecv = true
888885
889- case <- b . cfg . CancelReqChan :
890- cancelErr := b . Cancel ()
891- if cancelErr == nil {
886+ case err := <- errChan :
887+ b . cfg . ErrChan <- fmt . Errorf ( "error " +
888+ "getting confirmation: %w" , err )
892889 return
893- }
894890
895- log .Info (cancelErr )
891+ case <- confCtx .Done ():
892+ log .Debugf ("Skipping TX confirmation, " +
893+ "context done" )
894+ confRecv = true
896895
897- case <- b .Quit :
898- log .Debugf ("Skipping TX confirmation, exiting" )
899- return
896+ case <- b .cfg .CancelReqChan :
897+ cancelErr := b .Cancel ()
898+ if cancelErr == nil {
899+ return
900+ }
901+
902+ // Cancellation failed, continue to wait
903+ // for transaction confirmation.
904+ log .Info (cancelErr )
905+
906+ case <- b .Quit :
907+ log .Debugf ("Skipping TX confirmation, " +
908+ "exiting" )
909+ return
910+ }
900911 }
901912
902913 if confEvent == nil {
@@ -905,24 +916,31 @@ func (b *BatchCaretaker) stateStep(currentState BatchState) (BatchState, error)
905916 return
906917 }
907918
908- select {
909- case b .confEvent <- confEvent :
910-
911- case <- confCtx .Done ():
912- log .Debugf ("Skipping TX confirmation, context " +
913- "done" )
919+ for {
920+ select {
921+ case b .confEvent <- confEvent :
922+ return
914923
915- case <- b . cfg . CancelReqChan :
916- cancelErr := b . Cancel ()
917- if cancelErr == nil {
924+ case <- confCtx . Done () :
925+ log . Debugf ( "Skipping TX confirmation, " +
926+ "context done" )
918927 return
919- }
920928
921- log .Info (cancelErr )
929+ case <- b .cfg .CancelReqChan :
930+ cancelErr := b .Cancel ()
931+ if cancelErr == nil {
932+ return
933+ }
922934
923- case <- b .Quit :
924- log .Debugf ("Skipping TX confirmation, exiting" )
925- return
935+ // Cancellation failed, continue to try
936+ // and send the confirmation event.
937+ log .Info (cancelErr )
938+
939+ case <- b .Quit :
940+ log .Debugf ("Skipping TX confirmation, " +
941+ "exiting" )
942+ return
943+ }
926944 }
927945 }()
928946
0 commit comments