• 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

93.33
/record/hop.go
1
package record
2

3
import (
4
        "github.com/btcsuite/btcd/btcec/v2"
5
        "github.com/lightningnetwork/lnd/tlv"
6
)
7

8
const (
9
        // AmtOnionType is the type used in the onion to reference the amount to
10
        // send to the next hop.
11
        AmtOnionType tlv.Type = 2
12

13
        // LockTimeTLV is the type used in the onion to reference the CLTV
14
        // value that should be used for the next hop's HTLC.
15
        LockTimeOnionType tlv.Type = 4
16

17
        // NextHopOnionType is the type used in the onion to reference the ID
18
        // of the next hop.
19
        NextHopOnionType tlv.Type = 6
20

21
        // EncryptedDataOnionType is the type used to include encrypted data
22
        // provided by the receiver in the onion for use in blinded paths.
23
        EncryptedDataOnionType tlv.Type = 10
24

25
        // BlindingPointOnionType is the type used to include receiver provided
26
        // ephemeral keys in the onion that are used in blinded paths.
27
        BlindingPointOnionType tlv.Type = 12
28

29
        // MetadataOnionType is the type used in the onion for the payment
30
        // metadata.
31
        MetadataOnionType tlv.Type = 16
32

33
        // TotalAmtMsatBlindedType is the type used in the onion for the total
34
        // amount field that is included in the final hop for blinded payments.
35
        TotalAmtMsatBlindedType tlv.Type = 18
36
)
37

38
// NewAmtToFwdRecord creates a tlv.Record that encodes the amount_to_forward
39
// (type 2) for an onion payload.
40
func NewAmtToFwdRecord(amt *uint64) tlv.Record {
3✔
41
        return tlv.MakeDynamicRecord(
3✔
42
                AmtOnionType, amt, func() uint64 {
6✔
43
                        return tlv.SizeTUint64(*amt)
3✔
44
                },
3✔
45
                tlv.ETUint64, tlv.DTUint64,
46
        )
47
}
48

49
// NewLockTimeRecord creates a tlv.Record that encodes the outgoing_cltv_value
50
// (type 4) for an onion payload.
51
func NewLockTimeRecord(lockTime *uint32) tlv.Record {
3✔
52
        return tlv.MakeDynamicRecord(
3✔
53
                LockTimeOnionType, lockTime, func() uint64 {
6✔
54
                        return tlv.SizeTUint32(*lockTime)
3✔
55
                },
3✔
56
                tlv.ETUint32, tlv.DTUint32,
57
        )
58
}
59

60
// NewNextHopIDRecord creates a tlv.Record that encodes the short_channel_id
61
// (type 6) for an onion payload.
62
func NewNextHopIDRecord(cid *uint64) tlv.Record {
3✔
63
        return tlv.MakePrimitiveRecord(NextHopOnionType, cid)
3✔
64
}
3✔
65

66
// NewEncryptedDataRecord creates a tlv.Record that encodes the encrypted_data
67
// (type 10) record for an onion payload.
68
func NewEncryptedDataRecord(data *[]byte) tlv.Record {
3✔
69
        return tlv.MakePrimitiveRecord(EncryptedDataOnionType, data)
3✔
70
}
3✔
71

72
// NewBlindingPointRecord creates a tlv.Record that encodes the blinding_point
73
// (type 12) record for an onion payload.
74
func NewBlindingPointRecord(point **btcec.PublicKey) tlv.Record {
3✔
75
        return tlv.MakePrimitiveRecord(BlindingPointOnionType, point)
3✔
76
}
3✔
77

78
// NewMetadataRecord creates a tlv.Record that encodes the metadata (type 10)
79
// for an onion payload.
80
func NewMetadataRecord(metadata *[]byte) tlv.Record {
3✔
81
        return tlv.MakeDynamicRecord(
3✔
82
                MetadataOnionType, metadata,
3✔
83
                func() uint64 {
3✔
UNCOV
84
                        return uint64(len(*metadata))
×
UNCOV
85
                },
×
86
                tlv.EVarBytes, tlv.DVarBytes,
87
        )
88
}
89

90
// NewTotalAmtMsatBlinded creates a tlv.Record that encodes the
91
// total_amount_msat for the final an onion payload within a blinded route.
92
func NewTotalAmtMsatBlinded(amt *uint64) tlv.Record {
3✔
93
        return tlv.MakeDynamicRecord(
3✔
94
                TotalAmtMsatBlindedType, amt, func() uint64 {
6✔
95
                        return tlv.SizeTUint64(*amt)
3✔
96
                },
3✔
97
                tlv.ETUint64, tlv.DTUint64,
98
        )
99
}
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