Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1236,9 +1236,6 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
// will build a SQL payments backend.
sqlPaymentsDB, err := d.getPaymentsStore(
baseDB, dbs.ChanStateDB.Backend,
paymentsdb.WithKeepFailedPaymentAttempts(
cfg.KeepFailedPaymentAttempts,
),
)
if err != nil {
err = fmt.Errorf("unable to get payments store: %w",
Expand Down Expand Up @@ -1280,9 +1277,6 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
// Create the payments DB.
kvPaymentsDB, err := paymentsdb.NewKVStore(
dbs.ChanStateDB,
paymentsdb.WithKeepFailedPaymentAttempts(
cfg.KeepFailedPaymentAttempts,
),
)
if err != nil {
cleanUp()
Expand Down
4 changes: 4 additions & 0 deletions docs/release-notes/release-notes-0.21.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
for SQL backend](https://github.com/lightningnetwork/lnd/pull/10292)
* [Thread context through payment
db functions Part 1](https://github.com/lightningnetwork/lnd/pull/10307)
* [Thread context through payment
db functions Part 2](https://github.com/lightningnetwork/lnd/pull/10308)
* [Finalize SQL implementation for
payments db](https://github.com/lightningnetwork/lnd/pull/10373)


## Code Health
Expand Down
4 changes: 2 additions & 2 deletions lnrpc/routerrpc/router_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -936,11 +936,11 @@ func (s *Server) SendToRouteV2(ctx context.Context,
// db.
if req.SkipTempErr {
attempt, err = s.cfg.Router.SendToRouteSkipTempErr(
hash, route, firstHopRecords,
ctx, hash, route, firstHopRecords,
)
} else {
attempt, err = s.cfg.Router.SendToRoute(
hash, route, firstHopRecords,
ctx, hash, route, firstHopRecords,
)
}
if attempt != nil {
Expand Down
22 changes: 6 additions & 16 deletions payments/db/kv_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ type KVStore struct {

// db is the underlying database implementation.
db kvdb.Backend

// keepFailedPaymentAttempts is a flag that indicates whether we should
// keep failed payment attempts in the database.
keepFailedPaymentAttempts bool
}

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

return &KVStore{
db: db,
keepFailedPaymentAttempts: opts.KeepFailedPaymentAttempts,
db: db,
}, nil
}

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

// DeleteFailedAttempts deletes all failed htlcs for a payment if configured
// by the KVStore db.
// DeleteFailedAttempts deletes all failed htlcs for a payment.
func (p *KVStore) DeleteFailedAttempts(ctx context.Context,
hash lntypes.Hash) error {

// TODO(ziggie): Refactor to not mix application logic with database
// logic. This decision should be made in the application layer.
if !p.keepFailedPaymentAttempts {
const failedHtlcsOnly = true
err := p.DeletePayment(ctx, hash, failedHtlcsOnly)
if err != nil {
return err
}
const failedHtlcsOnly = true
err := p.DeletePayment(ctx, hash, failedHtlcsOnly)
if err != nil {
return err
}

return nil
Expand Down
Loading
Loading