multi: thread context through FailAttempt

This commit is contained in:
ziggie committed 2026-02-25 08:02:24 +01:00
1 parent 3b7fdabaec
commit 446300984e
10 files changed
+33 -26

No files matched your search

+2 -1
View File
@@ -90,7 +90,8 @@ type PaymentControl interface {
*HTLCSettleInfo) (*MPPayment, error)
// FailAttempt marks the given payment attempt failed.
FailAttempt(lntypes.Hash, uint64, *HTLCFailInfo) (*MPPayment, error)
FailAttempt(context.Context, lntypes.Hash, uint64,
*HTLCFailInfo) (*MPPayment, error)
// Fail transitions a payment into the Failed state, and records
// the ultimate reason the payment failed. Note that this should only
+1 -1
View File
@@ -443,7 +443,7 @@ func (p *KVStore) SettleAttempt(_ context.Context, hash lntypes.Hash,
}
// FailAttempt marks the given payment attempt failed.
func (p *KVStore) FailAttempt(hash lntypes.Hash,
func (p *KVStore) FailAttempt(_ context.Context, hash lntypes.Hash,
attemptID uint64, failInfo *HTLCFailInfo) (*MPPayment, error) {
var b bytes.Buffer
+1 -1
View File
@@ -100,7 +100,7 @@ func TestKVStoreDeleteNonInFlight(t *testing.T) {
// Fail the payment attempt.
htlcFailure := HTLCFailUnreadable
_, err := paymentDB.FailAttempt(
info.PaymentIdentifier, attempt.AttemptID,
ctx, info.PaymentIdentifier, attempt.AttemptID,
&HTLCFailInfo{
Reason: htlcFailure,
},
+6 -6
View File
@@ -156,7 +156,7 @@ func createTestPayments(t *testing.T, p DB, payments []*payment) {
htlcFailure := HTLCFailUnreadable
_, err = p.FailAttempt(
info.PaymentIdentifier, attempt.AttemptID,
ctx, info.PaymentIdentifier, attempt.AttemptID,
&HTLCFailInfo{
Reason: htlcFailure,
},
@@ -183,7 +183,7 @@ func createTestPayments(t *testing.T, p DB, payments []*payment) {
case StatusFailed:
htlcFailure := HTLCFailUnreadable
_, err = p.FailAttempt(
info.PaymentIdentifier, attempt.AttemptID,
ctx, info.PaymentIdentifier, attempt.AttemptID,
&HTLCFailInfo{
Reason: htlcFailure,
},
@@ -1885,7 +1885,7 @@ func TestSwitchFail(t *testing.T) {
htlcReason := HTLCFailUnreadable
_, err = paymentDB.FailAttempt(
info.PaymentIdentifier, attempt.AttemptID,
ctx, info.PaymentIdentifier, attempt.AttemptID,
&HTLCFailInfo{
Reason: htlcReason,
},
@@ -2069,7 +2069,7 @@ func TestMultiShard(t *testing.T) {
a := attempts[1]
htlcFail := HTLCFailUnreadable
_, err = paymentDB.FailAttempt(
info.PaymentIdentifier, a.AttemptID,
ctx, info.PaymentIdentifier, a.AttemptID,
&HTLCFailInfo{
Reason: htlcFail,
},
@@ -2118,7 +2118,7 @@ func TestMultiShard(t *testing.T) {
)
} else {
_, err := paymentDB.FailAttempt(
info.PaymentIdentifier, a.AttemptID,
ctx, info.PaymentIdentifier, a.AttemptID,
&HTLCFailInfo{
Reason: htlcFail,
},
@@ -2209,7 +2209,7 @@ func TestMultiShard(t *testing.T) {
} else {
// Fail the attempt.
_, err := paymentDB.FailAttempt(
info.PaymentIdentifier, a.AttemptID,
ctx, info.PaymentIdentifier, a.AttemptID,
&HTLCFailInfo{
Reason: htlcFail,
},
+1 -3
View File
@@ -1695,11 +1695,9 @@ func (s *SQLStore) SettleAttempt(ctx context.Context, paymentHash lntypes.Hash,
// the PaymentWriter interface and ultimately the DB interface. It represents
// step 3b in the payment lifecycle control flow (step 3a is SettleAttempt),
// called after RegisterAttempt when an HTLC fails.
func (s *SQLStore) FailAttempt(paymentHash lntypes.Hash,
func (s *SQLStore) FailAttempt(ctx context.Context, paymentHash lntypes.Hash,
attemptID uint64, failInfo *HTLCFailInfo) (*MPPayment, error) {
ctx := context.TODO()
var mpPayment *MPPayment
err := s.db.ExecTx(ctx, sqldb.WriteTxOpt(), func(db SQLQueries) error {