github.com/decred/dcrlnd@v0.7.6/channeldb/migration/lnwire21/update_fee.go (about) 1 package lnwire 2 3 import ( 4 "io" 5 ) 6 7 // UpdateFee is the message the channel initiator sends to the other peer if 8 // the channel commitment fee needs to be updated. 9 type UpdateFee struct { 10 // ChanID is the channel that this UpdateFee is meant for. 11 ChanID ChannelID 12 13 // FeePerKB is the fee-per-kB on commit transactions that the sender of 14 // this message wants to use for this channel. 15 // 16 // TODO(halseth): make AtomsPerKWeight when fee estimation is moved to 17 // own package. Currently this will cause an import cycle. 18 FeePerKB uint32 19 } 20 21 // NewUpdateFee creates a new UpdateFee message. 22 func NewUpdateFee(chanID ChannelID, feePerKB uint32) *UpdateFee { 23 return &UpdateFee{ 24 ChanID: chanID, 25 FeePerKB: feePerKB, 26 } 27 } 28 29 // A compile time check to ensure UpdateFee implements the lnwire.Message 30 // interface. 31 var _ Message = (*UpdateFee)(nil) 32 33 // Decode deserializes a serialized UpdateFee message stored in the passed 34 // io.Reader observing the specified protocol version. 35 // 36 // This is part of the lnwire.Message interface. 37 func (c *UpdateFee) Decode(r io.Reader, pver uint32) error { 38 return ReadElements(r, 39 &c.ChanID, 40 &c.FeePerKB, 41 ) 42 } 43 44 // Encode serializes the target UpdateFee into the passed io.Writer 45 // observing the protocol version specified. 46 // 47 // This is part of the lnwire.Message interface. 48 func (c *UpdateFee) Encode(w io.Writer, pver uint32) error { 49 return WriteElements(w, 50 c.ChanID, 51 c.FeePerKB, 52 ) 53 } 54 55 // MsgType returns the integer uniquely identifying this message type on the 56 // wire. 57 // 58 // This is part of the lnwire.Message interface. 59 func (c *UpdateFee) MsgType() MessageType { 60 return MsgUpdateFee 61 } 62 63 // MaxPayloadLength returns the maximum allowed payload size for an UpdateFee 64 // complete message observing the specified protocol version. 65 // 66 // This is part of the lnwire.Message interface. 67 func (c *UpdateFee) MaxPayloadLength(uint32) uint32 { 68 // 32 + 4 69 return 36 70 } 71 72 // TargetChanID returns the channel id of the link for which this message is 73 // intended. 74 // 75 // NOTE: Part of peer.LinkUpdater interface. 76 func (c *UpdateFee) TargetChanID() ChannelID { 77 return c.ChanID 78 }