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

lightningnetwork / lnd / 11170835610

03 Oct 2024 10:41PM UTC coverage: 49.188% (-9.6%) from 58.738%
11170835610

push

github

web-flow
Merge pull request #9154 from ziggie1984/master

multi: bump btcd version.

3 of 6 new or added lines in 6 files covered. (50.0%)

26110 existing lines in 428 files now uncovered.

97359 of 197934 relevant lines covered (49.19%)

1.04 hits per line

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

30.43
/feature/set.go
1
package feature
2

3
import (
4
        "math"
5

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

9
// Set is an enum identifying various feature sets, which separates the single
10
// feature namespace into distinct categories depending what context a feature
11
// vector is being used.
12
type Set uint8
13

14
const (
15
        // SetInit identifies features that should be sent in an Init message to
16
        // a remote peer.
17
        SetInit Set = iota
18

19
        // SetLegacyGlobal identifies features that should be set in the legacy
20
        // GlobalFeatures field of an Init message, which maintains backwards
21
        // compatibility with nodes that haven't implemented flat features.
22
        SetLegacyGlobal
23

24
        // SetNodeAnn identifies features that should be advertised on node
25
        // announcements.
26
        SetNodeAnn
27

28
        // SetInvoice identifies features that should be advertised on invoices
29
        // generated by the daemon.
30
        SetInvoice
31

32
        // SetInvoiceAmp identifies the features that should be advertised on
33
        // AMP invoices generated by the daemon.
34
        SetInvoiceAmp
35

36
        // setSentinel is used to mark the end of our known sets. This enum
37
        // member must *always* be the last item in the iota list to ensure
38
        // that validation works as expected.
39
        setSentinel
40
)
41

42
// valid returns a boolean indicating whether a set value is one of our
43
// predefined feature sets.
44
func (s Set) valid() bool {
2✔
45
        return s < setSentinel
2✔
46
}
2✔
47

48
// String returns a human-readable description of a Set.
49
func (s Set) String() string {
×
50
        switch s {
×
51
        case SetInit:
×
52
                return "SetInit"
×
53
        case SetLegacyGlobal:
×
54
                return "SetLegacyGlobal"
×
55
        case SetNodeAnn:
×
56
                return "SetNodeAnn"
×
57
        case SetInvoice:
×
58
                return "SetInvoice"
×
59
        case SetInvoiceAmp:
×
60
                return "SetInvoiceAmp"
×
61
        default:
×
62
                return "SetUnknown"
×
63
        }
64
}
65

66
// Maximum returns the maximum allowable value for a feature bit in the context
67
// of a set. The maximum feature value we can express differs by set context
68
// because the amount of space available varies between protocol messages. In
69
// practice this should never be a problem (reasonably one would never hit
70
// these high ranges), but we enforce these maximums for the sake of sane
71
// validation.
72
func (s Set) Maximum() lnwire.FeatureBit {
2✔
73
        switch s {
2✔
UNCOV
74
        case SetInvoice, SetInvoiceAmp:
×
UNCOV
75
                return lnwire.MaxBolt11Feature
×
76

77
        // The space available in other sets is > math.MaxUint16, so we just
78
        // return the maximum value our expression of a feature bit allows so
79
        // that any value will pass.
80
        default:
2✔
81
                return math.MaxUint16
2✔
82
        }
83
}
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