• 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

94.59
/lnwire/query_options.go
1
package lnwire
2

3
import (
4
        "io"
5

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

9
const (
10
        // QueryOptionsRecordType is the TLV number of the query_options TLV
11
        // record in the query_channel_range message.
12
        QueryOptionsRecordType tlv.Type = 1
13

14
        // QueryOptionTimestampBit is the bit position in the query_option
15
        // feature bit vector which is used to indicate that timestamps are
16
        // desired in the reply_channel_range response.
17
        QueryOptionTimestampBit = 0
18
)
19

20
// QueryOptions is the type used to represent the query_options feature bit
21
// vector in the query_channel_range message.
22
type QueryOptions RawFeatureVector
23

24
// NewTimestampQueryOption is a helper constructor used to construct a
25
// QueryOption with the timestamp bit set.
26
func NewTimestampQueryOption() *QueryOptions {
35✔
27
        opt := QueryOptions(*NewRawFeatureVector(
35✔
28
                QueryOptionTimestampBit,
35✔
29
        ))
35✔
30

35✔
31
        return &opt
35✔
32
}
35✔
33

34
// featureBitLen calculates and returns the size of the resulting feature bit
35
// vector.
36
func (c *QueryOptions) featureBitLen() uint64 {
83✔
37
        fv := RawFeatureVector(*c)
83✔
38

83✔
39
        return uint64(fv.SerializeSize())
83✔
40
}
83✔
41

42
// Record constructs a tlv.Record from the QueryOptions to be used in the
43
// query_channel_range message.
44
func (c *QueryOptions) Record() tlv.Record {
277✔
45
        return tlv.MakeDynamicRecord(
277✔
46
                QueryOptionsRecordType, c, c.featureBitLen, queryOptionsEncoder,
277✔
47
                queryOptionsDecoder,
277✔
48
        )
277✔
49
}
277✔
50

51
// queryOptionsEncoder encodes the QueryOptions and writes it to the provided
52
// writer.
53
func queryOptionsEncoder(w io.Writer, val interface{}, _ *[8]byte) error {
83✔
54
        if v, ok := val.(*QueryOptions); ok {
166✔
55
                // Encode the feature bits as a byte slice without its length
83✔
56
                // prepended, as that's already taken care of by the TLV record.
83✔
57
                fv := RawFeatureVector(*v)
83✔
58
                return fv.encode(w, fv.SerializeSize(), 8)
83✔
59
        }
83✔
60

61
        return tlv.NewTypeForEncodingErr(val, "lnwire.QueryOptions")
×
62
}
63

64
// queryOptionsDecoder attempts to read a QueryOptions from the given reader.
65
func queryOptionsDecoder(r io.Reader, val interface{}, _ *[8]byte,
66
        l uint64) error {
97✔
67

97✔
68
        if v, ok := val.(*QueryOptions); ok {
194✔
69
                fv := NewRawFeatureVector()
97✔
70
                if err := fv.decode(r, int(l), 8); err != nil {
99✔
71
                        return err
2✔
72
                }
2✔
73

74
                *v = QueryOptions(*fv)
95✔
75

95✔
76
                return nil
95✔
77
        }
78

79
        return tlv.NewTypeForEncodingErr(val, "lnwire.QueryOptions")
×
80
}
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