Merge pull request #3156 from joostjager/extended-fail
routerrpc: add more failure reasons and route hints
This commit is contained in:
11 files changed
+397
-199
No files matched your search
@@ -341,39 +341,41 @@ func (p *paymentLifecycle) sendPaymentAttempt(firstHop lnwire.ShortChannelID,
|
||||
// handleSendError inspects the given error from the Switch and determines
|
||||
// whether we should make another payment attempt.
|
||||
func (p *paymentLifecycle) handleSendError(sendErr error) error {
|
||||
var finalOutcome bool
|
||||
var reason channeldb.FailureReason
|
||||
|
||||
// If an internal, non-forwarding error occurred, we can stop trying.
|
||||
fErr, ok := sendErr.(*htlcswitch.ForwardingError)
|
||||
if !ok {
|
||||
finalOutcome = true
|
||||
reason = channeldb.FailureReasonError
|
||||
} else {
|
||||
finalOutcome = p.router.processSendError(
|
||||
var final bool
|
||||
final, reason = p.router.processSendError(
|
||||
p.paySession, &p.attempt.Route, fErr,
|
||||
)
|
||||
|
||||
// Save the forwarding error so it can be returned if this turns
|
||||
// out to be the last attempt.
|
||||
p.lastError = fErr
|
||||
}
|
||||
if !final {
|
||||
// Save the forwarding error so it can be returned if
|
||||
// this turns out to be the last attempt.
|
||||
p.lastError = fErr
|
||||
|
||||
if finalOutcome {
|
||||
log.Errorf("Payment %x failed with final outcome: %v",
|
||||
p.payment.PaymentHash, sendErr)
|
||||
|
||||
// Mark the payment failed with no route.
|
||||
// TODO(halseth): make payment codes for the actual reason we
|
||||
// don't continue path finding.
|
||||
err := p.router.cfg.Control.Fail(
|
||||
p.payment.PaymentHash, channeldb.FailureReasonNoRoute,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
// Terminal state, return the error we encountered.
|
||||
return sendErr
|
||||
}
|
||||
|
||||
return nil
|
||||
log.Debugf("Payment %x failed: final_outcome=%v, raw_err=%v",
|
||||
p.payment.PaymentHash, reason, sendErr)
|
||||
|
||||
// Mark the payment failed with no route.
|
||||
//
|
||||
// TODO(halseth): make payment codes for the actual reason we don't
|
||||
// continue path finding.
|
||||
err := p.router.cfg.Control.Fail(
|
||||
p.payment.PaymentHash, reason,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Terminal state, return the error we encountered.
|
||||
return sendErr
|
||||
}
|
||||
Reference in new issue
Block a user