htlcswitch: use distinct error for unreadable failures
This commit is contained in:
9 files changed
+396
-165
No files matched your search
@@ -17,7 +17,7 @@ import (
|
||||
type errNoRoute struct {
|
||||
// lastError is the error encountered during the last payment attempt,
|
||||
// if at least one attempt has been made.
|
||||
lastError *htlcswitch.ForwardingError
|
||||
lastError error
|
||||
}
|
||||
|
||||
// Error returns a string representation of the error.
|
||||
@@ -37,7 +37,7 @@ type paymentLifecycle struct {
|
||||
finalCLTVDelta uint16
|
||||
attempt *channeldb.PaymentAttemptInfo
|
||||
circuit *sphinx.Circuit
|
||||
lastError *htlcswitch.ForwardingError
|
||||
lastError error
|
||||
}
|
||||
|
||||
// resumePayment resumes the paymentLifecycle from the current state.
|
||||
@@ -341,25 +341,16 @@ 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 reason channeldb.FailureReason
|
||||
|
||||
// If an internal, non-forwarding error occurred, we can stop trying.
|
||||
fErr, ok := sendErr.(*htlcswitch.ForwardingError)
|
||||
if !ok {
|
||||
reason = channeldb.FailureReasonError
|
||||
} else {
|
||||
var final bool
|
||||
final, reason = p.router.processSendError(
|
||||
p.paySession, &p.attempt.Route, fErr,
|
||||
)
|
||||
final, reason := p.router.processSendError(
|
||||
p.paySession, &p.attempt.Route, sendErr,
|
||||
)
|
||||
if !final {
|
||||
// Save the forwarding error so it can be returned if
|
||||
// this turns out to be the last attempt.
|
||||
p.lastError = sendErr
|
||||
|
||||
if !final {
|
||||
// Save the forwarding error so it can be returned if
|
||||
// this turns out to be the last attempt.
|
||||
p.lastError = fErr
|
||||
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Debugf("Payment %x failed: final_outcome=%v, raw_err=%v",
|
||||
|
||||
Reference in new issue
Block a user