multi: thread context through Fail payment functions
This commit is contained in:
10 files changed
+41
-23
No files matched your search
@@ -364,11 +364,18 @@ func (p *paymentLifecycle) checkContext(ctx context.Context) error {
|
||||
p.identifier.String())
|
||||
}
|
||||
|
||||
// The context is already cancelled at this point, so we create
|
||||
// a new context so the payment can successfully be marked as
|
||||
// failed.
|
||||
cleanupCtx := context.WithoutCancel(ctx)
|
||||
|
||||
// By marking the payment failed, depending on whether it has
|
||||
// inflight HTLCs or not, its status will now either be
|
||||
// `StatusInflight` or `StatusFailed`. In either case, no more
|
||||
// HTLCs will be attempted.
|
||||
err := p.router.cfg.Control.FailPayment(p.identifier, reason)
|
||||
err := p.router.cfg.Control.FailPayment(
|
||||
cleanupCtx, p.identifier, reason,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("FailPayment got %w", err)
|
||||
}
|
||||
@@ -389,6 +396,8 @@ func (p *paymentLifecycle) checkContext(ctx context.Context) error {
|
||||
func (p *paymentLifecycle) requestRoute(
|
||||
ps *paymentsdb.MPPaymentState) (*route.Route, error) {
|
||||
|
||||
ctx := context.TODO()
|
||||
|
||||
remainingFees := p.calcFeeBudget(ps.FeesPaid)
|
||||
|
||||
// Query our payment session to construct a route.
|
||||
@@ -430,7 +439,9 @@ func (p *paymentLifecycle) requestRoute(
|
||||
log.Warnf("Marking payment %v permanently failed with no route: %v",
|
||||
p.identifier, failureCode)
|
||||
|
||||
err = p.router.cfg.Control.FailPayment(p.identifier, failureCode)
|
||||
err = p.router.cfg.Control.FailPayment(
|
||||
ctx, p.identifier, failureCode,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("FailPayment got: %w", err)
|
||||
}
|
||||
@@ -800,6 +811,8 @@ func (p *paymentLifecycle) failPaymentAndAttempt(
|
||||
attemptID uint64, reason *paymentsdb.FailureReason,
|
||||
sendErr error) (*attemptResult, error) {
|
||||
|
||||
ctx := context.TODO()
|
||||
|
||||
log.Errorf("Payment %v failed: final_outcome=%v, raw_err=%v",
|
||||
p.identifier, *reason, sendErr)
|
||||
|
||||
@@ -808,7 +821,9 @@ func (p *paymentLifecycle) failPaymentAndAttempt(
|
||||
// NOTE: we must fail the payment first before failing the attempt.
|
||||
// Otherwise, once the attempt is marked as failed, another goroutine
|
||||
// might make another attempt while we are failing the payment.
|
||||
err := p.router.cfg.Control.FailPayment(p.identifier, *reason)
|
||||
err := p.router.cfg.Control.FailPayment(
|
||||
ctx, p.identifier, *reason,
|
||||
)
|
||||
if err != nil {
|
||||
log.Errorf("Unable to fail payment: %v", err)
|
||||
return nil, err
|
||||
|
||||
Reference in new issue
Block a user