channeldb+router: record payment failure reason in db

This commit is contained in:
Johan T. Halseth committed 2019-05-27 20:18:59 +02:00
1 parent 60e2367973
commit 1b788904f0
5 files changed
+106 -23

No files matched your search

+4 -2
View File
@@ -167,6 +167,7 @@ type successArgs struct {
}
type failArgs struct {
reason channeldb.FailureReason
}
type mockControlTower struct {
@@ -253,13 +254,14 @@ func (m *mockControlTower) Success(phash lntypes.Hash,
return nil
}
func (m *mockControlTower) Fail(phash lntypes.Hash) error {
func (m *mockControlTower) Fail(phash lntypes.Hash,
reason channeldb.FailureReason) error {
m.Lock()
defer m.Unlock()
if m.fail != nil {
m.fail <- failArgs{}
m.fail <- failArgs{reason}
}
delete(m.inflights, phash)
+3 -3
View File
@@ -177,7 +177,7 @@ func (p *paymentLifecycle) createNewPaymentAttempt() (lnwire.ShortChannelID,
// Mark the payment as failed because of the
// timeout.
err := p.router.cfg.Control.Fail(
p.payment.PaymentHash,
p.payment.PaymentHash, channeldb.FailureReasonTimeout,
)
if err != nil {
return lnwire.ShortChannelID{}, nil, err
@@ -208,7 +208,7 @@ func (p *paymentLifecycle) createNewPaymentAttempt() (lnwire.ShortChannelID,
// any of the routes we've found, then mark the payment
// as permanently failed.
saveErr := p.router.cfg.Control.Fail(
p.payment.PaymentHash,
p.payment.PaymentHash, channeldb.FailureReasonNoRoute,
)
if saveErr != nil {
return lnwire.ShortChannelID{}, nil, saveErr
@@ -338,7 +338,7 @@ func (p *paymentLifecycle) handleSendError(sendErr error) error {
// TODO(halseth): make payment codes for the actual reason we
// don't continue path finding.
err := p.router.cfg.Control.Fail(
p.payment.PaymentHash,
p.payment.PaymentHash, channeldb.FailureReasonNoRoute,
)
if err != nil {
return err