Skip to content

Commit 03c6ed7

Browse files
committed
routing: add context to failAttempt
1 parent be71aef commit 03c6ed7

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

routing/payment_lifecycle.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ func (p *paymentLifecycle) sendAttempt(ctx context.Context,
693693
"payment=%v, err:%v", attempt.AttemptID,
694694
p.identifier, err)
695695

696-
return p.failAttempt(attempt.AttemptID, err)
696+
return p.failAttempt(ctx, attempt.AttemptID, err)
697697
}
698698

699699
htlcAdd.OnionBlob = onionBlob
@@ -819,7 +819,7 @@ func (p *paymentLifecycle) failPaymentAndAttempt(ctx context.Context,
819819
}
820820

821821
// Fail the attempt.
822-
return p.failAttempt(attemptID, sendErr)
822+
return p.failAttempt(ctx, attemptID, sendErr)
823823
}
824824

825825
// handleSwitchErr inspects the given error from the Switch and determines
@@ -858,7 +858,7 @@ func (p *paymentLifecycle) handleSwitchErr(ctx context.Context,
858858
// Fail the attempt only if there's no reason.
859859
if reason == nil {
860860
// Fail the attempt.
861-
return p.failAttempt(attemptID, sendErr)
861+
return p.failAttempt(ctx, attemptID, sendErr)
862862
}
863863

864864
// Otherwise fail both the payment and the attempt.
@@ -873,7 +873,7 @@ func (p *paymentLifecycle) handleSwitchErr(ctx context.Context,
873873
log.Warnf("Failing attempt=%v for payment=%v as it's not "+
874874
"found in the Switch", attempt.AttemptID, p.identifier)
875875

876-
return p.failAttempt(attemptID, sendErr)
876+
return p.failAttempt(ctx, attemptID, sendErr)
877877
}
878878

879879
if errors.Is(sendErr, htlcswitch.ErrUnreadableFailureMessage) {
@@ -1005,11 +1005,9 @@ func (p *paymentLifecycle) handleFailureMessage(rt *route.Route,
10051005
}
10061006

10071007
// failAttempt calls control tower to fail the current payment attempt.
1008-
func (p *paymentLifecycle) failAttempt(attemptID uint64,
1008+
func (p *paymentLifecycle) failAttempt(ctx context.Context, attemptID uint64,
10091009
sendError error) (*attemptResult, error) {
10101010

1011-
ctx := context.TODO()
1012-
10131011
log.Warnf("Attempt %v for payment %v failed: %v", attemptID,
10141012
p.identifier, sendError)
10151013

0 commit comments

Comments
 (0)