routing: convert to nillable failure reason

This commit converts several functions from returning a bool and a
failure reason to a nillable failure reason as return parameter. This
will take away confusion about the interpretation of the two separate
values.
This commit is contained in:
Joost Jager
2019-08-05 12:13:58 +02:00
parent d134e0362e
commit e7af6a077a
4 changed files with 31 additions and 25 deletions

View File

@ -342,10 +342,10 @@ func (p *paymentLifecycle) sendPaymentAttempt(firstHop lnwire.ShortChannelID,
// whether we should make another payment attempt.
func (p *paymentLifecycle) handleSendError(sendErr error) error {
final, reason := p.router.processSendError(
reason := p.router.processSendError(
p.attempt.PaymentID, &p.attempt.Route, sendErr,
)
if !final {
if reason == nil {
// Save the forwarding error so it can be returned if
// this turns out to be the last attempt.
p.lastError = sendErr
@ -354,14 +354,14 @@ func (p *paymentLifecycle) handleSendError(sendErr error) error {
}
log.Debugf("Payment %x failed: final_outcome=%v, raw_err=%v",
p.payment.PaymentHash, reason, sendErr)
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,
p.payment.PaymentHash, *reason,
)
if err != nil {
return err