• 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

0.0
/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
// NewWarning creates a new Warning message.
33
func NewWarning() *Warning {
×
34
        return &Warning{}
×
35
}
×
36

37
// Warning returns the string representation to Warning.
UNCOV
38
func (c *Warning) Warning() string {
×
UNCOV
39
        errMsg := "non-ascii data"
×
UNCOV
40
        if isASCII(c.Data) {
×
UNCOV
41
                errMsg = string(c.Data)
×
UNCOV
42
        }
×
43

UNCOV
44
        return fmt.Sprintf("chan_id=%v, err=%v", c.ChanID, errMsg)
×
45
}
46

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

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

UNCOV
67
        return WriteWarningData(w, c.Data)
×
68
}
69

70
// MsgType returns the integer uniquely identifying an Warning message on the
71
// wire.
72
//
73
// This is part of the lnwire.Message interface.
UNCOV
74
func (c *Warning) MsgType() MessageType {
×
UNCOV
75
        return MsgWarning
×
UNCOV
76
}
×
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