From 5b06854850a75f83e244baa898ff636acd2a19ed Mon Sep 17 00:00:00 2001 From: ziggie Date: Tue, 21 Oct 2025 11:42:35 +0200 Subject: [PATCH] routing: add context to failAttempt --- routing/payment_lifecycle.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/routing/payment_lifecycle.go b/routing/payment_lifecycle.go index b5df24379..c6f6154c1 100644 --- a/routing/payment_lifecycle.go +++ b/routing/payment_lifecycle.go @@ -713,7 +713,7 @@ func (p *paymentLifecycle) sendAttempt(ctx context.Context, "payment=%v, err:%v", attempt.AttemptID, p.identifier, err) - return p.failAttempt(attempt.AttemptID, err) + return p.failAttempt(ctx, attempt.AttemptID, err) } htlcAdd.OnionBlob = onionBlob @@ -839,7 +839,7 @@ func (p *paymentLifecycle) failPaymentAndAttempt(ctx context.Context, } // Fail the attempt. - return p.failAttempt(attemptID, sendErr) + return p.failAttempt(ctx, attemptID, sendErr) } // handleSwitchErr inspects the given error from the Switch and determines @@ -878,7 +878,7 @@ func (p *paymentLifecycle) handleSwitchErr(ctx context.Context, // Fail the attempt only if there's no reason. if reason == nil { // Fail the attempt. - return p.failAttempt(attemptID, sendErr) + return p.failAttempt(ctx, attemptID, sendErr) } // Otherwise fail both the payment and the attempt. @@ -893,7 +893,7 @@ func (p *paymentLifecycle) handleSwitchErr(ctx context.Context, log.Warnf("Failing attempt=%v for payment=%v as it's not "+ "found in the Switch", attempt.AttemptID, p.identifier) - return p.failAttempt(attemptID, sendErr) + return p.failAttempt(ctx, attemptID, sendErr) } if errors.Is(sendErr, htlcswitch.ErrUnreadableFailureMessage) { @@ -1025,11 +1025,9 @@ func (p *paymentLifecycle) handleFailureMessage(rt *route.Route, } // failAttempt calls control tower to fail the current payment attempt. -func (p *paymentLifecycle) failAttempt(attemptID uint64, +func (p *paymentLifecycle) failAttempt(ctx context.Context, attemptID uint64, sendError error) (*attemptResult, error) { - ctx := context.TODO() - log.Warnf("Attempt %v for payment %v failed: %v", attemptID, p.identifier, sendError)