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

lightningnetwork / lnd / 14193549836

01 Apr 2025 10:40AM UTC coverage: 69.046% (+0.007%) from 69.039%
14193549836

Pull #9665

github

web-flow
Merge e8825f209 into b01f4e514
Pull Request #9665: kvdb: bump etcd libs to v3.5.12

133439 of 193262 relevant lines covered (69.05%)

22119.45 hits per line

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

68.97
/channeldb/migration32/migration.go
1
package migration32
2

3
import (
4
        "bytes"
5
        "fmt"
6

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

10
// MigrateMCRouteSerialisation reads all the mission control store entries and
11
// re-serializes them using a minimal route serialisation so that only the parts
12
// of the route that are actually required for mission control are persisted.
13
func MigrateMCRouteSerialisation(tx kvdb.RwTx) error {
1✔
14
        log.Infof("Migrating Mission Control store to use a more minimal " +
1✔
15
                "encoding for routes")
1✔
16

1✔
17
        resultBucket := tx.ReadWriteBucket(resultsKey)
1✔
18

1✔
19
        // If the results bucket does not exist then there are no entries in
1✔
20
        // the mission control store yet and so there is nothing to migrate.
1✔
21
        if resultBucket == nil {
1✔
22
                return nil
×
23
        }
×
24

25
        // For each entry, read it into memory using the old encoding. Then,
26
        // extract the more minimal route, re-encode and persist the entry.
27
        return resultBucket.ForEach(func(k, v []byte) error {
3✔
28
                // Read the entry using the old encoding.
2✔
29
                resultOld, err := deserializeOldResult(k, v)
2✔
30
                if err != nil {
2✔
31
                        return err
×
32
                }
×
33

34
                // Convert to the new payment result format with the minimal
35
                // route.
36
                resultNew := convertPaymentResult(resultOld)
2✔
37

2✔
38
                // Serialise the new payment result using the new encoding.
2✔
39
                key, resultNewBytes, err := serializeNewResult(resultNew)
2✔
40
                if err != nil {
2✔
41
                        return err
×
42
                }
×
43

44
                // Make sure that the derived key is the same.
45
                if !bytes.Equal(key, k) {
2✔
46
                        return fmt.Errorf("new payment result key (%v) is "+
×
47
                                "not the same as the old key (%v)", key, k)
×
48
                }
×
49

50
                // Finally, overwrite the previous value with the new encoding.
51
                return resultBucket.Put(k, resultNewBytes)
2✔
52
        })
53
}
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