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

lightningnetwork / lnd / 13035292482

29 Jan 2025 03:59PM UTC coverage: 49.3% (-9.5%) from 58.777%
13035292482

Pull #9456

github

mohamedawnallah
docs: update release-notes-0.19.0.md

In this commit, we warn users about the removal
of RPCs `SendToRoute`, `SendToRouteSync`, `SendPayment`,
and `SendPaymentSync` in the next release 0.20.
Pull Request #9456: lnrpc+docs: deprecate warning `SendToRoute`, `SendToRouteSync`, `SendPayment`, and `SendPaymentSync` in Release 0.19

100634 of 204126 relevant lines covered (49.3%)

1.54 hits per line

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

0.0
/watchtower/wtdb/migration5/client_db.go
1
package migration5
2

3
import (
4
        "encoding/binary"
5
        "errors"
6

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

10
var (
11
        // cTowerBkt is a top-level bucket storing:
12
        //    tower-id -> encoded Tower.
13
        cTowerBkt = []byte("client-tower-bucket")
14

15
        // cTowerIDToSessionIDIndexBkt is a top-level bucket storing:
16
        //         tower-id -> session-id -> 1
17
        cTowerIDToSessionIDIndexBkt = []byte(
18
                "client-tower-to-session-index-bucket",
19
        )
20

21
        // ErrUninitializedDB signals that top-level buckets for the database
22
        // have not been initialized.
23
        ErrUninitializedDB = errors.New("db not initialized")
24

25
        // byteOrder is the default endianness used when serializing integers.
26
        byteOrder = binary.BigEndian
27
)
28

29
// MigrateCompleteTowerToSessionIndex ensures that the tower-to-session index
30
// contains entries for all towers in the db. This is necessary because
31
// migration1 only created entries in the index for towers that the client had
32
// at least one session with. This migration thus makes sure that there is
33
// always a tower-to-sessions index entry for a tower even if there are no
34
// sessions with that tower.
35
func MigrateCompleteTowerToSessionIndex(tx kvdb.RwTx) error {
×
36
        log.Infof("Migrating the tower client db to ensure that there is an " +
×
37
                "entry in the towerID-to-sessionID index for every tower in " +
×
38
                "the db")
×
39

×
40
        // First, we collect all the towers that we should add an entry for in
×
41
        // the index.
×
42
        towerIDs, err := listTowerIDs(tx)
×
43
        if err != nil {
×
44
                return err
×
45
        }
×
46

47
        // Create a new top-level bucket for the index if it does not yet exist.
48
        indexBkt, err := tx.CreateTopLevelBucket(cTowerIDToSessionIDIndexBkt)
×
49
        if err != nil {
×
50
                return err
×
51
        }
×
52

53
        // Finally, ensure that there is an entry in the tower-to-session index
54
        // for each of our towers.
55
        for _, id := range towerIDs {
×
56
                // Create a sub-bucket using the tower ID.
×
57
                _, err := indexBkt.CreateBucketIfNotExists(id.Bytes())
×
58
                if err != nil {
×
59
                        return err
×
60
                }
×
61
        }
62

63
        return nil
×
64
}
65

66
// listTowerIDs iterates through the cTowerBkt and collects a list of all the
67
// TowerIDs.
68
func listTowerIDs(tx kvdb.RTx) ([]*TowerID, error) {
×
69
        var ids []*TowerID
×
70
        towerBucket := tx.ReadBucket(cTowerBkt)
×
71
        if towerBucket == nil {
×
72
                return nil, ErrUninitializedDB
×
73
        }
×
74

75
        err := towerBucket.ForEach(func(towerIDBytes, _ []byte) error {
×
76
                id, err := TowerIDFromBytes(towerIDBytes)
×
77
                if err != nil {
×
78
                        return err
×
79
                }
×
80

81
                ids = append(ids, &id)
×
82

×
83
                return nil
×
84
        })
85
        if err != nil {
×
86
                return nil, err
×
87
        }
×
88

89
        return ids, nil
×
90
}
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