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

lightningnetwork / lnd / 15561477203

10 Jun 2025 01:54PM UTC coverage: 58.351% (-10.1%) from 68.487%
15561477203

Pull #9356

github

web-flow
Merge 6440b25db into c6d6d4c0b
Pull Request #9356: lnrpc: add incoming/outgoing channel ids filter to forwarding history request

33 of 36 new or added lines in 2 files covered. (91.67%)

28366 existing lines in 455 files now uncovered.

97715 of 167461 relevant lines covered (58.35%)

1.81 hits per line

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

0.0
/lnwire/ping.go
1
package lnwire
2

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

8
// PingPayload is a set of opaque bytes used to pad out a ping message.
9
type PingPayload []byte
10

11
// Ping defines a message which is sent by peers periodically to determine if
12
// the connection is still valid. Each ping message carries the number of bytes
13
// to pad the pong response with, and also a number of bytes to be ignored at
14
// the end of the ping message (which is padding).
15
type Ping struct {
16
        // NumPongBytes is the number of bytes the pong response to this
17
        // message should carry.
18
        NumPongBytes uint16
19

20
        // PaddingBytes is a set of opaque bytes used to pad out this ping
21
        // message. Using this field in conjunction to the one above, it's
22
        // possible for node to generate fake cover traffic.
23
        PaddingBytes PingPayload
24
}
25

26
// NewPing returns a new Ping message.
UNCOV
27
func NewPing(numBytes uint16) *Ping {
×
UNCOV
28
        return &Ping{
×
UNCOV
29
                NumPongBytes: numBytes,
×
UNCOV
30
        }
×
UNCOV
31
}
×
32

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

36
// A compile time check to ensure Ping implements the lnwire.SizeableMessage
37
// interface.
38
var _ SizeableMessage = (*Ping)(nil)
39

40
// Decode deserializes a serialized Ping message stored in the passed io.Reader
41
// observing the specified protocol version.
42
//
43
// This is part of the lnwire.Message interface.
UNCOV
44
func (p *Ping) Decode(r io.Reader, pver uint32) error {
×
UNCOV
45
        err := ReadElements(r, &p.NumPongBytes, &p.PaddingBytes)
×
UNCOV
46
        if err != nil {
×
UNCOV
47
                return err
×
UNCOV
48
        }
×
49

UNCOV
50
        if p.NumPongBytes > MaxPongBytes {
×
UNCOV
51
                return ErrMaxPongBytesExceeded
×
UNCOV
52
        }
×
53

UNCOV
54
        return nil
×
55
}
56

57
// Encode serializes the target Ping into the passed io.Writer observing the
58
// protocol version specified.
59
//
60
// This is part of the lnwire.Message interface.
UNCOV
61
func (p *Ping) Encode(w *bytes.Buffer, pver uint32) error {
×
UNCOV
62
        if err := WriteUint16(w, p.NumPongBytes); err != nil {
×
63
                return err
×
64
        }
×
65

UNCOV
66
        return WritePingPayload(w, p.PaddingBytes)
×
67
}
68

69
// MsgType returns the integer uniquely identifying this message type on the
70
// wire.
71
//
72
// This is part of the lnwire.Message interface.
UNCOV
73
func (p *Ping) MsgType() MessageType {
×
UNCOV
74
        return MsgPing
×
UNCOV
75
}
×
76

77
// SerializedSize returns the serialized size of the message in bytes.
78
//
79
// This is part of the lnwire.SizeableMessage interface.
80
func (p *Ping) SerializedSize() (uint32, error) {
×
81
        return MessageSerializedSize(p)
×
82
}
×
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