Skip to content

Commit d8531d2

Browse files
authored
Merge pull request #10373 from ziggie1984/introduce-sql-schema-payments-part-7
[Part 7|*] Addressing TODOs left from the SQL payments implementation
2 parents 5453d57 + fb82814 commit d8531d2

File tree

12 files changed

+855
-477
lines changed

12 files changed

+855
-477
lines changed

config_builder.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,9 +1236,6 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
12361236
// will build a SQL payments backend.
12371237
sqlPaymentsDB, err := d.getPaymentsStore(
12381238
baseDB, dbs.ChanStateDB.Backend,
1239-
paymentsdb.WithKeepFailedPaymentAttempts(
1240-
cfg.KeepFailedPaymentAttempts,
1241-
),
12421239
)
12431240
if err != nil {
12441241
err = fmt.Errorf("unable to get payments store: %w",
@@ -1280,9 +1277,6 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
12801277
// Create the payments DB.
12811278
kvPaymentsDB, err := paymentsdb.NewKVStore(
12821279
dbs.ChanStateDB,
1283-
paymentsdb.WithKeepFailedPaymentAttempts(
1284-
cfg.KeepFailedPaymentAttempts,
1285-
),
12861280
)
12871281
if err != nil {
12881282
cleanUp()

docs/release-notes/release-notes-0.21.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
db functions Part 1](https://github.com/lightningnetwork/lnd/pull/10307)
8888
* [Thread context through payment
8989
db functions Part 2](https://github.com/lightningnetwork/lnd/pull/10308)
90+
* [Finalize SQL implementation for
91+
payments db](https://github.com/lightningnetwork/lnd/pull/10373)
9092

9193

9294
## Code Health

payments/db/kv_store.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ type KVStore struct {
127127

128128
// db is the underlying database implementation.
129129
db kvdb.Backend
130-
131-
// keepFailedPaymentAttempts is a flag that indicates whether we should
132-
// keep failed payment attempts in the database.
133-
keepFailedPaymentAttempts bool
134130
}
135131

136132
// A compile-time constraint to ensure KVStore implements DB.
@@ -152,8 +148,7 @@ func NewKVStore(db kvdb.Backend,
152148
}
153149

154150
return &KVStore{
155-
db: db,
156-
keepFailedPaymentAttempts: opts.KeepFailedPaymentAttempts,
151+
db: db,
157152
}, nil
158153
}
159154

@@ -288,19 +283,14 @@ func (p *KVStore) InitPayment(_ context.Context, paymentHash lntypes.Hash,
288283
return updateErr
289284
}
290285

291-
// DeleteFailedAttempts deletes all failed htlcs for a payment if configured
292-
// by the KVStore db.
286+
// DeleteFailedAttempts deletes all failed htlcs for a payment.
293287
func (p *KVStore) DeleteFailedAttempts(ctx context.Context,
294288
hash lntypes.Hash) error {
295289

296-
// TODO(ziggie): Refactor to not mix application logic with database
297-
// logic. This decision should be made in the application layer.
298-
if !p.keepFailedPaymentAttempts {
299-
const failedHtlcsOnly = true
300-
err := p.DeletePayment(ctx, hash, failedHtlcsOnly)
301-
if err != nil {
302-
return err
303-
}
290+
const failedHtlcsOnly = true
291+
err := p.DeletePayment(ctx, hash, failedHtlcsOnly)
292+
if err != nil {
293+
return err
304294
}
305295

306296
return nil

0 commit comments

Comments
 (0)