mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-28 13:52:55 +02:00
lnwire: refactor Encode to use specific writers - III
This commit refactors the remaining usage of WriteElements. By replacing the interface types with concrete types for the params used in the methods, most of the encoding of the messages now takes zero heap allocations.
This commit is contained in:
@@ -87,22 +87,28 @@ func (c *ReplyChannelRange) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *ReplyChannelRange) Encode(w *bytes.Buffer, pver uint32) error {
|
||||
err := WriteElements(w,
|
||||
c.ChainHash[:],
|
||||
c.FirstBlockHeight,
|
||||
c.NumBlocks,
|
||||
c.Complete,
|
||||
)
|
||||
if err := WriteBytes(w, c.ChainHash[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := WriteUint32(w, c.FirstBlockHeight); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := WriteUint32(w, c.NumBlocks); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := WriteUint8(w, c.Complete); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err := encodeShortChanIDs(w, c.EncodingType, c.ShortChanIDs, c.noSort)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = encodeShortChanIDs(w, c.EncodingType, c.ShortChanIDs, c.noSort)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.ExtraData.Encode(w)
|
||||
return WriteBytes(w, c.ExtraData)
|
||||
}
|
||||
|
||||
// MsgType returns the integer uniquely identifying this message type on the
|
||||
|
Reference in New Issue
Block a user