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

lightningnetwork / lnd / 12199391122

06 Dec 2024 01:10PM UTC coverage: 49.807% (-9.1%) from 58.933%
12199391122

push

github

web-flow
Merge pull request #9337 from Guayaba221/patch-1

chore: fix typo in ruby.md

100137 of 201051 relevant lines covered (49.81%)

2.07 hits per line

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

89.19
/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 {
4✔
27
        opt := QueryOptions(*NewRawFeatureVector(
4✔
28
                QueryOptionTimestampBit,
4✔
29
        ))
4✔
30

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

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

4✔
39
        return uint64(fv.SerializeSize())
4✔
40
}
4✔
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 {
4✔
45
        return tlv.MakeDynamicRecord(
4✔
46
                QueryOptionsRecordType, c, c.featureBitLen, queryOptionsEncoder,
4✔
47
                queryOptionsDecoder,
4✔
48
        )
4✔
49
}
4✔
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 {
4✔
54
        if v, ok := val.(*QueryOptions); ok {
8✔
55
                // Encode the feature bits as a byte slice without its length
4✔
56
                // prepended, as that's already taken care of by the TLV record.
4✔
57
                fv := RawFeatureVector(*v)
4✔
58
                return fv.encode(w, fv.SerializeSize(), 8)
4✔
59
        }
4✔
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 {
4✔
67

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

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

4✔
76
                return nil
4✔
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