• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 18140636176

30 Sep 2025 07:05PM UTC coverage: 66.58%. First build
18140636176

Pull #9147

github

web-flow
Merge ca3b10b13 into 90c96c7df
Pull Request #9147: [Part 1|3] Introduce SQL Payment schema into LND

9 of 47 new or added lines in 3 files covered. (19.15%)

136724 of 205352 relevant lines covered (66.58%)

21321.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/payments/db/sql_store.go
1
package paymentsdb
2

3
import (
4
        "fmt"
5

6
        "github.com/lightningnetwork/lnd/sqldb"
7
)
8

9
// SQLQueries is a subset of the sqlc.Querier interface that can be used to
10
// execute queries against the SQL payments tables.
11
type SQLQueries interface {
12
}
13

14
// BatchedSQLQueries is a version of the SQLQueries that's capable
15
// of batched database operations.
16
type BatchedSQLQueries interface {
17
        SQLQueries
18
        sqldb.BatchedTx[SQLQueries]
19
}
20

21
// SQLStore represents a storage backend.
22
type SQLStore struct {
23
        // TODO(ziggie): Remove the KVStore once all the interface functions are
24
        // implemented.
25
        KVStore
26

27
        cfg *SQLStoreConfig
28
        db  BatchedSQLQueries
29

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

35
// A compile-time constraint to ensure SQLStore implements DB.
36
var _ DB = (*SQLStore)(nil)
37

38
// SQLStoreConfig holds the configuration for the SQLStore.
39
type SQLStoreConfig struct {
40
        // QueryConfig holds configuration values for SQL queries.
41
        QueryCfg *sqldb.QueryConfig
42
}
43

44
// NewSQLStore creates a new SQLStore instance given an open
45
// BatchedSQLPaymentsQueries storage backend.
46
func NewSQLStore(cfg *SQLStoreConfig, db BatchedSQLQueries,
NEW
47
        options ...OptionModifier) (*SQLStore, error) {
×
NEW
48

×
NEW
49
        opts := DefaultOptions()
×
NEW
50
        for _, applyOption := range options {
×
NEW
51
                applyOption(opts)
×
NEW
52
        }
×
53

NEW
54
        if opts.NoMigration {
×
NEW
55
                return nil, fmt.Errorf("the NoMigration option is not yet " +
×
NEW
56
                        "supported for SQL stores")
×
NEW
57
        }
×
58

NEW
59
        return &SQLStore{
×
NEW
60
                cfg:                       cfg,
×
NEW
61
                db:                        db,
×
NEW
62
                keepFailedPaymentAttempts: opts.KeepFailedPaymentAttempts,
×
NEW
63
        }, nil
×
64
}
65

66
// A compile-time constraint to ensure SQLStore implements DB.
67
var _ DB = (*SQLStore)(nil)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc