github.com/decred/dcrlnd@v0.7.6/lnwire/reply_short_chan_ids_end.go (about) 1 package lnwire 2 3 import ( 4 "bytes" 5 "io" 6 7 "github.com/decred/dcrd/chaincfg/chainhash" 8 ) 9 10 // ReplyShortChanIDsEnd is a message that marks the end of a streaming message 11 // response to an initial QueryShortChanIDs message. This marks that the 12 // receiver of the original QueryShortChanIDs for the target chain has either 13 // sent all adequate responses it knows of, or doesn't know of any short chan 14 // ID's for the target chain. 15 type ReplyShortChanIDsEnd struct { 16 // ChainHash denotes the target chain that we're respond to a short 17 // chan ID query for. 18 ChainHash chainhash.Hash 19 20 // Complete will be set to 0 if we don't know of the chain that the 21 // remote peer sent their query for. Otherwise, we'll set this to 1 in 22 // order to indicate that we've sent all known responses for the prior 23 // set of short chan ID's in the corresponding QueryShortChanIDs 24 // message. 25 Complete uint8 26 27 // ExtraData is the set of data that was appended to this message to 28 // fill out the full maximum transport message size. These fields can 29 // be used to specify optional data such as custom TLV fields. 30 ExtraData ExtraOpaqueData 31 } 32 33 // NewReplyShortChanIDsEnd creates a new empty ReplyShortChanIDsEnd message. 34 func NewReplyShortChanIDsEnd() *ReplyShortChanIDsEnd { 35 return &ReplyShortChanIDsEnd{} 36 } 37 38 // A compile time check to ensure ReplyShortChanIDsEnd implements the 39 // lnwire.Message interface. 40 var _ Message = (*ReplyShortChanIDsEnd)(nil) 41 42 // Decode deserializes a serialized ReplyShortChanIDsEnd message stored in the 43 // passed io.Reader observing the specified protocol version. 44 // 45 // This is part of the lnwire.Message interface. 46 func (c *ReplyShortChanIDsEnd) Decode(r io.Reader, pver uint32) error { 47 return ReadElements(r, 48 c.ChainHash[:], 49 &c.Complete, 50 &c.ExtraData, 51 ) 52 } 53 54 // Encode serializes the target ReplyShortChanIDsEnd into the passed io.Writer 55 // observing the protocol version specified. 56 // 57 // This is part of the lnwire.Message interface. 58 func (c *ReplyShortChanIDsEnd) Encode(w *bytes.Buffer, pver uint32) error { 59 if err := WriteBytes(w, c.ChainHash[:]); err != nil { 60 return err 61 } 62 63 if err := WriteUint8(w, c.Complete); err != nil { 64 return err 65 } 66 67 return WriteBytes(w, c.ExtraData) 68 } 69 70 // MsgType returns the integer uniquely identifying this message type on the 71 // wire. 72 // 73 // This is part of the lnwire.Message interface. 74 func (c *ReplyShortChanIDsEnd) MsgType() MessageType { 75 return MsgReplyShortChanIDsEnd 76 }