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

lightningnetwork / lnd / 13566028875

27 Feb 2025 12:09PM UTC coverage: 49.396% (-9.4%) from 58.748%
13566028875

Pull #9555

github

ellemouton
graph/db: populate the graph cache in Start instead of during construction

In this commit, we move the graph cache population logic out of the
ChannelGraph constructor and into its Start method instead.
Pull Request #9555: graph: extract cache from CRUD [6]

34 of 54 new or added lines in 4 files covered. (62.96%)

27464 existing lines in 436 files now uncovered.

101095 of 204664 relevant lines covered (49.4%)

1.54 hits per line

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

0.0
/channeldb/migration33/migration.go
1
package migration33
2

3
import (
4
        "bytes"
5

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

9
var (
10
        // resultsKey is the fixed key under which the attempt results are
11
        // stored.
12
        resultsKey = []byte("missioncontrol-results")
13

14
        // defaultMCNamespaceKey is the key of the default mission control store
15
        // namespace.
16
        defaultMCNamespaceKey = []byte("default")
17
)
18

19
// MigrateMCStoreNameSpacedResults reads in all the current mission control
20
// entries and re-writes them under a new default namespace.
UNCOV
21
func MigrateMCStoreNameSpacedResults(tx kvdb.RwTx) error {
×
UNCOV
22
        log.Infof("Migrating Mission Control store to use namespaced results")
×
UNCOV
23

×
UNCOV
24
        // Get the top level bucket. All the MC results are currently stored
×
UNCOV
25
        // as KV pairs in this bucket
×
UNCOV
26
        topLevelBucket := tx.ReadWriteBucket(resultsKey)
×
UNCOV
27

×
UNCOV
28
        // If the results bucket does not exist then there are no entries in
×
UNCOV
29
        // the mission control store yet and so there is nothing to migrate.
×
UNCOV
30
        if topLevelBucket == nil {
×
31
                return nil
×
32
        }
×
33

34
        // Create a new default namespace bucket under the top-level bucket.
UNCOV
35
        defaultNSBkt, err := topLevelBucket.CreateBucket(defaultMCNamespaceKey)
×
UNCOV
36
        if err != nil {
×
37
                return err
×
38
        }
×
39

40
        // Iterate through each of the existing result pairs, write them to the
41
        // new namespaced bucket. Also collect the set of keys so that we can
42
        // later delete them from the top level bucket.
UNCOV
43
        var keys [][]byte
×
UNCOV
44
        err = topLevelBucket.ForEach(func(k, v []byte) error {
×
UNCOV
45
                // Skip the new default namespace key.
×
UNCOV
46
                if bytes.Equal(k, defaultMCNamespaceKey) {
×
UNCOV
47
                        return nil
×
UNCOV
48
                }
×
49

50
                // Collect the key.
UNCOV
51
                keys = append(keys, k)
×
UNCOV
52

×
UNCOV
53
                // Write the pair under the default namespace.
×
UNCOV
54
                return defaultNSBkt.Put(k, v)
×
55
        })
UNCOV
56
        if err != nil {
×
57
                return err
×
58
        }
×
59

60
        // Finally, iterate through the set of keys and delete them from the
61
        // top level bucket.
UNCOV
62
        for _, k := range keys {
×
UNCOV
63
                if err := topLevelBucket.Delete(k); err != nil {
×
64
                        return err
×
65
                }
×
66
        }
67

UNCOV
68
        return err
×
69
}
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