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:
yyforyongyu committed 2021-08-10 05:36:09 +08:00
1 parent c1ad9cc60f
commit 2cf6969dbc
12 files changed
+289 -133

No files matched your search

+9 -5
View File
@@ -53,11 +53,15 @@ func (c *UpdateFee) Decode(r io.Reader, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (c *UpdateFee) Encode(w *bytes.Buffer, pver uint32) error {
return WriteElements(w,
c.ChanID,
c.FeePerKw,
c.ExtraData,
)
if err := WriteChannelID(w, c.ChanID); err != nil {
return err
}
if err := WriteUint32(w, c.FeePerKw); err != nil {
return err
}
return WriteBytes(w, c.ExtraData)
}
// MsgType returns the integer uniquely identifying this message type on the