diff --git a/htlcswitch/payment_result.go b/htlcswitch/payment_result.go index fa14f37a8..cd5fe0a56 100644 --- a/htlcswitch/payment_result.go +++ b/htlcswitch/payment_result.go @@ -128,6 +128,8 @@ func (store *networkResultStore) storeResult(paymentID uint64, store.paymentIDMtx.Lock(paymentID) defer store.paymentIDMtx.Unlock(paymentID) + log.Debugf("Storing result for paymentID=%v", paymentID) + // Serialize the payment result. var b bytes.Buffer if err := serializeNetworkResult(&b, result); err != nil { @@ -175,6 +177,8 @@ func (store *networkResultStore) subscribeResult(paymentID uint64) ( store.paymentIDMtx.Lock(paymentID) defer store.paymentIDMtx.Unlock(paymentID) + log.Debugf("Subscribing to result for paymentID=%v", paymentID) + var ( result *networkResult resultChan = make(chan *networkResult, 1) diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index 1f755bb07..5648695fe 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -420,6 +420,9 @@ func (s *Switch) GetPaymentResult(paymentID uint64, paymentHash lntypes.Hash, return } + log.Debugf("Received network result %T for paymentID=%v", n.msg, + paymentID) + // Extract the result and pass it to the result channel. result, err := s.extractResult( deobfuscator, n, paymentID, paymentHash, diff --git a/routing/payment_lifecycle.go b/routing/payment_lifecycle.go index 30a076682..0e61dec1c 100644 --- a/routing/payment_lifecycle.go +++ b/routing/payment_lifecycle.go @@ -14,6 +14,9 @@ import ( "github.com/lightningnetwork/lnd/routing/route" ) +// errShardHandlerExiting is returned from the shardHandler when it exits. +var errShardHandlerExiting = fmt.Errorf("shard handler exiting") + // paymentLifecycle holds all information about the current state of a payment // needed to resume if from any point. type paymentLifecycle struct { @@ -104,7 +107,7 @@ func (p *paymentLifecycle) resumePayment() ([32]byte, *route.Route, error) { for _, a := range payment.InFlightHTLCs() { a := a - log.Debugf("Resuming payment shard %v for hash %v", + log.Infof("Resuming payment shard %v for hash %v", a.AttemptID, p.paymentHash) shardHandler.collectResultAsync(&a.HTLCAttemptInfo) @@ -308,7 +311,7 @@ func (p *shardHandler) waitForShard() error { return err case <-p.quit: - return fmt.Errorf("shard handler quitting") + return errShardHandlerExiting case <-p.router.quit: return ErrRouterShuttingDown @@ -326,7 +329,7 @@ func (p *shardHandler) checkShards() error { } case <-p.quit: - return fmt.Errorf("shard handler quitting") + return errShardHandlerExiting case <-p.router.quit: return ErrRouterShuttingDown @@ -421,7 +424,8 @@ func (p *shardHandler) collectResultAsync(attempt *channeldb.HTLCAttemptInfo) { result, err := p.collectResult(attempt) if err != nil { if err != ErrRouterShuttingDown && - err != htlcswitch.ErrSwitchExiting { + err != htlcswitch.ErrSwitchExiting && + err != errShardHandlerExiting { log.Errorf("Error collecting result for "+ "shard %v for payment %v: %v", @@ -531,7 +535,7 @@ func (p *shardHandler) collectResult(attempt *channeldb.HTLCAttemptInfo) ( return nil, ErrRouterShuttingDown case <-p.quit: - return nil, fmt.Errorf("shard handler exiting") + return nil, errShardHandlerExiting } // In case of a payment failure, fail the attempt with the control @@ -683,7 +687,7 @@ func (p *shardHandler) handleSendError(attempt *channeldb.HTLCAttemptInfo, return nil } - log.Debugf("Payment %v failed: final_outcome=%v, raw_err=%v", + log.Infof("Payment %v failed: final_outcome=%v, raw_err=%v", p.paymentHash, *reason, sendErr) err := p.router.cfg.Control.Fail(p.paymentHash, *reason) diff --git a/routing/router.go b/routing/router.go index af1e8d75f..4e4bcbefb 100644 --- a/routing/router.go +++ b/routing/router.go @@ -2006,8 +2006,8 @@ func (r *ChannelRouter) tryApplyChannelUpdate(rt *route.Route, // processSendError analyzes the error for the payment attempt received from the // switch and updates mission control and/or channel policies. Depending on the // error type, this error is either the final outcome of the payment or we need -// to continue with an alternative route. This is indicated by the boolean -// return value. +// to continue with an alternative route. A final outcome is indicated by a +// non-nil return value. func (r *ChannelRouter) processSendError(paymentID uint64, rt *route.Route, sendErr error) *channeldb.FailureReason {