2018-04-16 18:46:33 -07:00
|
|
|
package lnwire
|
|
|
|
|
|
|
|
import (
|
2021-06-17 14:17:30 +08:00
|
|
|
"bytes"
|
2018-04-16 18:46:33 -07:00
|
|
|
"io"
|
|
|
|
|
2018-06-04 18:34:16 -07:00
|
|
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
2018-04-16 18:46:33 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// ReplyShortChanIDsEnd is a message that marks the end of a streaming message
|
|
|
|
// response to an initial QueryShortChanIDs message. This marks that the
|
|
|
|
// receiver of the original QueryShortChanIDs for the target chain has either
|
2020-11-26 05:12:29 +08:00
|
|
|
// sent all adequate responses it knows of, or doesn't know of any short chan
|
2018-04-16 18:46:33 -07:00
|
|
|
// ID's for the target chain.
|
|
|
|
type ReplyShortChanIDsEnd struct {
|
|
|
|
// ChainHash denotes the target chain that we're respond to a short
|
|
|
|
// chan ID query for.
|
|
|
|
ChainHash chainhash.Hash
|
|
|
|
|
|
|
|
// Complete will be set to 0 if we don't know of the chain that the
|
|
|
|
// remote peer sent their query for. Otherwise, we'll set this to 1 in
|
|
|
|
// order to indicate that we've sent all known responses for the prior
|
|
|
|
// set of short chan ID's in the corresponding QueryShortChanIDs
|
|
|
|
// message.
|
|
|
|
Complete uint8
|
2020-01-27 17:25:36 -08:00
|
|
|
|
|
|
|
// ExtraData is the set of data that was appended to this message to
|
|
|
|
// fill out the full maximum transport message size. These fields can
|
|
|
|
// be used to specify optional data such as custom TLV fields.
|
|
|
|
ExtraData ExtraOpaqueData
|
2018-04-16 18:46:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewReplyShortChanIDsEnd creates a new empty ReplyShortChanIDsEnd message.
|
|
|
|
func NewReplyShortChanIDsEnd() *ReplyShortChanIDsEnd {
|
|
|
|
return &ReplyShortChanIDsEnd{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// A compile time check to ensure ReplyShortChanIDsEnd implements the
|
|
|
|
// lnwire.Message interface.
|
|
|
|
var _ Message = (*ReplyShortChanIDsEnd)(nil)
|
|
|
|
|
|
|
|
// Decode deserializes a serialized ReplyShortChanIDsEnd message stored in the
|
|
|
|
// passed io.Reader observing the specified protocol version.
|
|
|
|
//
|
|
|
|
// This is part of the lnwire.Message interface.
|
|
|
|
func (c *ReplyShortChanIDsEnd) Decode(r io.Reader, pver uint32) error {
|
2018-12-09 18:27:41 -08:00
|
|
|
return ReadElements(r,
|
2018-04-16 18:46:33 -07:00
|
|
|
c.ChainHash[:],
|
|
|
|
&c.Complete,
|
2020-01-27 17:25:36 -08:00
|
|
|
&c.ExtraData,
|
2018-04-16 18:46:33 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Encode serializes the target ReplyShortChanIDsEnd into the passed io.Writer
|
|
|
|
// observing the protocol version specified.
|
|
|
|
//
|
|
|
|
// This is part of the lnwire.Message interface.
|
2021-06-17 14:17:30 +08:00
|
|
|
func (c *ReplyShortChanIDsEnd) Encode(w *bytes.Buffer, pver uint32) error {
|
2021-06-18 15:11:43 +08:00
|
|
|
if err := WriteBytes(w, c.ChainHash[:]); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := WriteUint8(w, c.Complete); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return WriteBytes(w, c.ExtraData)
|
2018-04-16 18:46:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// MsgType returns the integer uniquely identifying this message type on the
|
|
|
|
// wire.
|
|
|
|
//
|
|
|
|
// This is part of the lnwire.Message interface.
|
|
|
|
func (c *ReplyShortChanIDsEnd) MsgType() MessageType {
|
|
|
|
return MsgReplyShortChanIDsEnd
|
|
|
|
}
|