mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-20 13:53:19 +02:00
lnwire: place ping and pong in the correct files :p
This commit is contained in:
parent
7a990b3b10
commit
83c72eb082
@ -2,41 +2,40 @@ package lnwire
|
|||||||
|
|
||||||
import "io"
|
import "io"
|
||||||
|
|
||||||
// Pong defines a message which is the direct response to a received Ping
|
// Ping defines a message which is sent by peers periodically to determine if
|
||||||
// message. A Pong reply indicates that a connection is still active. The Pong
|
// the connection is still valid. Each ping message should carry a unique nonce
|
||||||
// reply to a Ping message should contain the nonce carried in the original
|
// which is to be echoed back within the Pong response.
|
||||||
// Pong message.
|
type Ping struct {
|
||||||
type Pong struct {
|
// Nonce is a unique value associated with this ping message. The pong
|
||||||
// Nonce is the unique nonce that was associated with the Ping message
|
// message that responds to this ping should reference the same value.
|
||||||
// that this Pong is replying to.
|
|
||||||
Nonce uint64
|
Nonce uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPong returns a new Pong message binded to the specified nonce.
|
// NewPing returns a new Ping message binded to the specified nonce.
|
||||||
func NewPong(nonce uint64) *Pong {
|
func NewPing(nonce uint64) *Ping {
|
||||||
return &Pong{
|
return &Ping{
|
||||||
Nonce: nonce,
|
Nonce: nonce,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A compile time check to ensure Pong implements the lnwire.Message interface.
|
// A compile time check to ensure Ping implements the lnwire.Message interface.
|
||||||
var _ Message = (*Pong)(nil)
|
var _ Message = (*Ping)(nil)
|
||||||
|
|
||||||
// Decode deserializes a serialized Pong message stored in the passed io.Reader
|
// Decode deserializes a serialized Ping message stored in the passed io.Reader
|
||||||
// observing the specified protocol version.
|
// observing the specified protocol version.
|
||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (p *Pong) Decode(r io.Reader, pver uint32) error {
|
func (p *Ping) Decode(r io.Reader, pver uint32) error {
|
||||||
return readElements(r,
|
return readElements(r,
|
||||||
&p.Nonce,
|
&p.Nonce,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode serializes the target Pong into the passed io.Writer observing the
|
// Encode serializes the target Ping into the passed io.Writer observing the
|
||||||
// protocol version specified.
|
// protocol version specified.
|
||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (p *Pong) Encode(w io.Writer, pver uint32) error {
|
func (p *Ping) Encode(w io.Writer, pver uint32) error {
|
||||||
return writeElements(w,
|
return writeElements(w,
|
||||||
p.Nonce,
|
p.Nonce,
|
||||||
)
|
)
|
||||||
@ -46,22 +45,22 @@ func (p *Pong) Encode(w io.Writer, pver uint32) error {
|
|||||||
// wire.
|
// wire.
|
||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (p *Pong) Command() uint32 {
|
func (p *Ping) Command() uint32 {
|
||||||
return CmdPong
|
return CmdPing
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxPayloadLength returns the maximum allowed payload size for a Pong
|
// MaxPayloadLength returns the maximum allowed payload size for a Ping
|
||||||
// complete message observing the specified protocol version.
|
// complete message observing the specified protocol version.
|
||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (p *Pong) MaxPayloadLength(uint32) uint32 {
|
func (p Ping) MaxPayloadLength(uint32) uint32 {
|
||||||
return 8
|
return 8
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
// Validate performs any necessary sanity checks to ensure all fields present
|
||||||
// on the Pong are valid.
|
// on the Ping are valid.
|
||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (p *Pong) Validate() error {
|
func (p *Ping) Validate() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -2,40 +2,41 @@ package lnwire
|
|||||||
|
|
||||||
import "io"
|
import "io"
|
||||||
|
|
||||||
// Ping defines a message which is sent by peers periodically to determine if
|
// Pong defines a message which is the direct response to a received Ping
|
||||||
// the connection is still valid. Each ping message should carry a unique nonce
|
// message. A Pong reply indicates that a connection is still active. The Pong
|
||||||
// which is to be echoed back within the Pong response.
|
// reply to a Ping message should contain the nonce carried in the original
|
||||||
type Ping struct {
|
// Pong message.
|
||||||
// Nonce is a unique value associated with this ping message. The pong
|
type Pong struct {
|
||||||
// message that responds to this ping should reference the same value.
|
// Nonce is the unique nonce that was associated with the Ping message
|
||||||
|
// that this Pong is replying to.
|
||||||
Nonce uint64
|
Nonce uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPing returns a new Ping message binded to the specified nonce.
|
// NewPong returns a new Pong message binded to the specified nonce.
|
||||||
func NewPing(nonce uint64) *Ping {
|
func NewPong(nonce uint64) *Pong {
|
||||||
return &Ping{
|
return &Pong{
|
||||||
Nonce: nonce,
|
Nonce: nonce,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A compile time check to ensure Ping implements the lnwire.Message interface.
|
// A compile time check to ensure Pong implements the lnwire.Message interface.
|
||||||
var _ Message = (*Ping)(nil)
|
var _ Message = (*Pong)(nil)
|
||||||
|
|
||||||
// Decode deserializes a serialized Ping message stored in the passed io.Reader
|
// Decode deserializes a serialized Pong message stored in the passed io.Reader
|
||||||
// observing the specified protocol version.
|
// observing the specified protocol version.
|
||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (p *Ping) Decode(r io.Reader, pver uint32) error {
|
func (p *Pong) Decode(r io.Reader, pver uint32) error {
|
||||||
return readElements(r,
|
return readElements(r,
|
||||||
&p.Nonce,
|
&p.Nonce,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode serializes the target Ping into the passed io.Writer observing the
|
// Encode serializes the target Pong into the passed io.Writer observing the
|
||||||
// protocol version specified.
|
// protocol version specified.
|
||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (p *Ping) Encode(w io.Writer, pver uint32) error {
|
func (p *Pong) Encode(w io.Writer, pver uint32) error {
|
||||||
return writeElements(w,
|
return writeElements(w,
|
||||||
p.Nonce,
|
p.Nonce,
|
||||||
)
|
)
|
||||||
@ -45,22 +46,22 @@ func (p *Ping) Encode(w io.Writer, pver uint32) error {
|
|||||||
// wire.
|
// wire.
|
||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (p *Ping) Command() uint32 {
|
func (p *Pong) Command() uint32 {
|
||||||
return CmdPing
|
return CmdPong
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxPayloadLength returns the maximum allowed payload size for a Ping
|
// MaxPayloadLength returns the maximum allowed payload size for a Pong
|
||||||
// complete message observing the specified protocol version.
|
// complete message observing the specified protocol version.
|
||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (p Ping) MaxPayloadLength(uint32) uint32 {
|
func (p *Pong) MaxPayloadLength(uint32) uint32 {
|
||||||
return 8
|
return 8
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
// Validate performs any necessary sanity checks to ensure all fields present
|
||||||
// on the Ping are valid.
|
// on the Pong are valid.
|
||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (p *Ping) Validate() error {
|
func (p *Pong) Validate() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user