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

lightningnetwork / lnd / 11124677510

01 Oct 2024 11:49AM UTC coverage: 58.814% (+0.08%) from 58.735%
11124677510

push

github

web-flow
Merge pull request #8911 from ellemouton/reduceMCRouteEncoding

routing+channeldb: use a more minimal encoding for MC routes

561 of 893 new or added lines in 12 files covered. (62.82%)

60 existing lines in 15 files now uncovered.

130302 of 221548 relevant lines covered (58.81%)

28707.83 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✔
NEW
22
                return nil
×
NEW
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✔
NEW
31
                        return err
×
NEW
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✔
NEW
41
                        return err
×
NEW
42
                }
×
43

44
                // Make sure that the derived key is the same.
45
                if !bytes.Equal(key, k) {
2✔
NEW
46
                        return fmt.Errorf("new payment result key (%v) is "+
×
NEW
47
                                "not the same as the old key (%v)", key, k)
×
NEW
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