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