• 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

66.67
/lnwire/typed_fee.go
1
package lnwire
2

3
import (
4
        "io"
5

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

9
const (
10
        FeeRecordType tlv.Type = 55555
11
)
12

13
// Fee represents a fee schedule.
14
type Fee struct {
15
        BaseFee int32
16
        FeeRate int32
17
}
18

19
// Record returns a TLV record that can be used to encode/decode the fee
20
// type from a given TLV stream.
21
func (l *Fee) Record() tlv.Record {
3✔
22
        return tlv.MakeStaticRecord(
3✔
23
                FeeRecordType, l, 8, feeEncoder, feeDecoder, //nolint:gomnd
3✔
24
        )
3✔
25
}
3✔
26

27
// feeEncoder is a custom TLV encoder for the fee record.
28
func feeEncoder(w io.Writer, val interface{}, buf *[8]byte) error {
3✔
29
        v, ok := val.(*Fee)
3✔
30
        if !ok {
3✔
31
                return tlv.NewTypeForEncodingErr(val, "lnwire.Fee")
×
32
        }
×
33

34
        if err := tlv.EUint32T(w, uint32(v.BaseFee), buf); err != nil {
3✔
35
                return err
×
36
        }
×
37

38
        return tlv.EUint32T(w, uint32(v.FeeRate), buf)
3✔
39
}
40

41
// feeDecoder is a custom TLV decoder for the fee record.
42
func feeDecoder(r io.Reader, val interface{}, buf *[8]byte, l uint64) error {
3✔
43
        v, ok := val.(*Fee)
3✔
44
        if !ok {
3✔
45
                return tlv.NewTypeForDecodingErr(val, "lnwire.Fee", l, 8)
×
46
        }
×
47

48
        var baseFee, feeRate uint32
3✔
49
        if err := tlv.DUint32(r, &baseFee, buf, 4); err != nil {
3✔
UNCOV
50
                return err
×
UNCOV
51
        }
×
52
        if err := tlv.DUint32(r, &feeRate, buf, 4); err != nil {
3✔
UNCOV
53
                return err
×
UNCOV
54
        }
×
55

56
        v.FeeRate = int32(feeRate)
3✔
57
        v.BaseFee = int32(baseFee)
3✔
58

3✔
59
        return nil
3✔
60
}
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