• 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

80.77
/lnwire/warning.go
1
package lnwire
2

3
import (
4
        "bytes"
5
        "fmt"
6
        "io"
7
)
8

9
// WarningData is a set of bytes associated with a particular sent warning. A
10
// receiving node SHOULD only print out data verbatim if the string is composed
11
// solely of printable ASCII characters. For reference, the printable character
12
// set includes byte values 32 through 127 inclusive.
13
type WarningData []byte
14

15
// Warning is used to express non-critical errors in the protocol, providing
16
// a "soft" way for nodes to communicate failures.
17
type Warning struct {
18
        // ChanID references the active channel in which the warning occurred
19
        // within. If the ChanID is all zeros, then this warning applies to the
20
        // entire established connection.
21
        ChanID ChannelID
22

23
        // Data is the attached warning data that describes the exact failure
24
        // which caused the warning message to be sent.
25
        Data WarningData
26
}
27

28
// A compile time check to ensure Warning implements the lnwire.Message
29
// interface.
30
var _ Message = (*Warning)(nil)
31

32
// A compile time check to ensure Warning implements the lnwire.SizeableMessage
33
// interface.
34
var _ SizeableMessage = (*Warning)(nil)
35

36
// NewWarning creates a new Warning message.
37
func NewWarning() *Warning {
×
38
        return &Warning{}
×
39
}
×
40

41
// Warning returns the string representation to Warning.
42
func (c *Warning) Warning() string {
43✔
43
        errMsg := "non-ascii data"
43✔
44
        if isASCII(c.Data) {
86✔
45
                errMsg = string(c.Data)
43✔
46
        }
43✔
47

48
        return fmt.Sprintf("chan_id=%v, err=%v", c.ChanID, errMsg)
43✔
49
}
50

51
// Decode deserializes a serialized Warning message stored in the passed
52
// io.Reader observing the specified protocol version.
53
//
54
// This is part of the lnwire.Message interface.
55
func (c *Warning) Decode(r io.Reader, _ uint32) error {
113✔
56
        return ReadElements(r,
113✔
57
                &c.ChanID,
113✔
58
                &c.Data,
113✔
59
        )
113✔
60
}
113✔
61

62
// Encode serializes the target Warning into the passed io.Writer observing the
63
// protocol version specified.
64
//
65
// This is part of the lnwire.Message interface.
66
func (c *Warning) Encode(w *bytes.Buffer, _ uint32) error {
128✔
67
        if err := WriteBytes(w, c.ChanID[:]); err != nil {
128✔
68
                return err
×
69
        }
×
70

71
        return WriteWarningData(w, c.Data)
128✔
72
}
73

74
// MsgType returns the integer uniquely identifying an Warning message on the
75
// wire.
76
//
77
// This is part of the lnwire.Message interface.
78
func (c *Warning) MsgType() MessageType {
119✔
79
        return MsgWarning
119✔
80
}
119✔
81

82
// SerializedSize returns the serialized size of the message in bytes.
83
//
84
// This is part of the lnwire.SizeableMessage interface.
85
func (c *Warning) SerializedSize() (uint32, error) {
12✔
86
        return MessageSerializedSize(c)
12✔
87
}
12✔
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