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

lightningnetwork / lnd / 15106677698

19 May 2025 07:14AM UTC coverage: 68.977%. First build
15106677698

Pull #9823

github

web-flow
Merge 7a89612eb into b857ae5e6
Pull Request #9823: graph/db: final test preparation before SQL impl

6 of 30 new or added lines in 3 files covered. (20.0%)

133943 of 194185 relevant lines covered (68.98%)

22039.18 hits per line

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

0.0
/graph/db/sql_store.go
1
package graphdb
2

3
import (
4
        "sync"
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 graph tables.
11
type SQLQueries interface {
12
}
13

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

21
// SQLStore is an implementation of the V1Store interface that uses a SQL
22
// database as the backend.
23
//
24
// NOTE: currently, this temporarily embeds the KVStore struct so that we can
25
// implement the V1Store interface incrementally. For any method not
26
// implemented,  things will fall back to the KVStore. This is ONLY the case
27
// for the time being while this struct is purely used in unit tests only.
28
type SQLStore struct {
29
        db BatchedSQLQueries
30

31
        // cacheMu guards all caches (rejectCache and chanCache). If
32
        // this mutex will be acquired at the same time as the DB mutex (ie if
33
        // a transaction is starting) then the cacheMu MUST be acquired first to
34
        // prevent deadlock.
35
        cacheMu     sync.RWMutex //nolint:unused
36
        rejectCache *rejectCache
37
        chanCache   *channelCache
38

39
        // Temporary fall-back to the KVStore so that we can implement the
40
        // interface incrementally.
41
        *KVStore
42
}
43

44
// A compile-time assertion to ensure that SQLStore implements the V1Store
45
// interface.
46
var _ V1Store = (*SQLStore)(nil)
47

48
// NewSQLStore creates a new SQLStore instance given an open BatchedSQLQueries
49
// storage backend.
50
func NewSQLStore(db BatchedSQLQueries, kvStore *KVStore,
NEW
51
        options ...SQLStoreOption) *SQLStore {
×
NEW
52

×
NEW
53
        opts := DefaultSQLOptions()
×
NEW
54
        for _, o := range options {
×
NEW
55
                o(opts)
×
NEW
56
        }
×
57

58
        return &SQLStore{
×
NEW
59
                db:          db,
×
NEW
60
                KVStore:     kvStore,
×
NEW
61
                rejectCache: newRejectCache(opts.RejectCacheSize),
×
NEW
62
                chanCache:   newChannelCache(opts.ChannelCacheSize),
×
63
        }
×
64
}
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