multi: thread context through Fail payment functions

This commit is contained in:
ziggie committed 2026-02-25 08:02:24 +01:00
1 parent 446300984e
commit 635a67c94a
10 files changed
+41 -23

No files matched your search

+1 -1
View File
@@ -99,7 +99,7 @@ type PaymentControl interface {
// invoking this method, InitPayment should return nil on its next call
// for this payment hash, allowing the user to make a subsequent
// payment.
Fail(lntypes.Hash, FailureReason) (*MPPayment, error)
Fail(context.Context, lntypes.Hash, FailureReason) (*MPPayment, error)
// DeleteFailedAttempts removes all failed HTLCs from the db. It should
// be called for a given payment whenever all inflight htlcs are
+1 -1
View File
@@ -528,7 +528,7 @@ func (p *KVStore) updateHtlcKey(paymentHash lntypes.Hash,
// payment failed. After invoking this method, InitPayment should return nil on
// its next call for this payment hash, allowing the switch to make a
// subsequent payment.
func (p *KVStore) Fail(paymentHash lntypes.Hash,
func (p *KVStore) Fail(_ context.Context, paymentHash lntypes.Hash,
reason FailureReason) (*MPPayment, error) {
var (
+1 -1
View File
@@ -112,7 +112,7 @@ func TestKVStoreDeleteNonInFlight(t *testing.T) {
// Fail the payment, which should moved it to Failed.
failReason := FailureReasonNoRoute
_, err = paymentDB.Fail(
info.PaymentIdentifier, failReason,
ctx, info.PaymentIdentifier, failReason,
)
if err != nil {
t.Fatalf("unable to fail payment hash: %v", err)
+7 -6
View File
@@ -191,8 +191,9 @@ func createTestPayments(t *testing.T, p DB, payments []*payment) {
require.NoError(t, err, "unable to fail htlc")
failReason := FailureReasonNoRoute
_, err = p.Fail(info.PaymentIdentifier,
failReason)
_, err = p.Fail(
ctx, info.PaymentIdentifier, failReason,
)
require.NoError(t, err, "unable to fail payment hash")
// Settle the attempt
@@ -1667,7 +1668,7 @@ func TestFailsWithoutInFlight(t *testing.T) {
// Calling Fail should return an error.
_, err = paymentDB.Fail(
info.PaymentIdentifier, FailureReasonNoRoute,
t.Context(), info.PaymentIdentifier, FailureReasonNoRoute,
)
require.ErrorIs(t, err, ErrPaymentNotInitiated)
}
@@ -1843,7 +1844,7 @@ func TestSwitchFail(t *testing.T) {
// Fail the payment, which should moved it to Failed.
failReason := FailureReasonNoRoute
_, err = paymentDB.Fail(info.PaymentIdentifier, failReason)
_, err = paymentDB.Fail(ctx, info.PaymentIdentifier, failReason)
require.NoError(t, err, "unable to fail payment hash")
// Verify the status is indeed Failed.
@@ -2139,7 +2140,7 @@ func TestMultiShard(t *testing.T) {
// a terminal state.
failReason := FailureReasonNoRoute
_, err = paymentDB.Fail(
info.PaymentIdentifier, failReason,
ctx, info.PaymentIdentifier, failReason,
)
if err != nil {
t.Fatalf("unable to fail payment hash: %v", err)
@@ -2232,7 +2233,7 @@ func TestMultiShard(t *testing.T) {
// syncing.
failReason := FailureReasonPaymentDetails
_, err = paymentDB.Fail(
info.PaymentIdentifier, failReason,
ctx, info.PaymentIdentifier, failReason,
)
require.NoError(t, err, "unable to fail")
}
+1 -3
View File
@@ -1782,11 +1782,9 @@ func (s *SQLStore) FailAttempt(ctx context.Context, paymentHash lntypes.Hash,
// This method is part of the PaymentControl interface, which is embedded in
// the PaymentWriter interface and ultimately the DB interface. It represents
// step 4 in the payment lifecycle control flow.
func (s *SQLStore) Fail(paymentHash lntypes.Hash,
func (s *SQLStore) Fail(ctx context.Context, paymentHash lntypes.Hash,
reason FailureReason) (*MPPayment, error) {
ctx := context.TODO()
var mpPayment *MPPayment
err := s.db.ExecTx(ctx, sqldb.WriteTxOpt(), func(db SQLQueries) error {