lnwire: refactor Encode to use specific writers - II

This commit takes another 10 message types and refactors their Encode
method to use specific writers. The following commit will refactor the
rest.
This commit is contained in:
yyforyongyu
2021-06-18 15:11:43 +08:00
parent 563ff7266a
commit c1ad9cc60f
10 changed files with 213 additions and 87 deletions

View File

@@ -56,11 +56,15 @@ func (c *ReplyShortChanIDsEnd) Decode(r io.Reader, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (c *ReplyShortChanIDsEnd) Encode(w *bytes.Buffer, pver uint32) error {
return WriteElements(w,
c.ChainHash[:],
c.Complete,
c.ExtraData,
)
if err := WriteBytes(w, c.ChainHash[:]); err != nil {
return err
}
if err := WriteUint8(w, c.Complete); err != nil {
return err
}
return WriteBytes(w, c.ExtraData)
}
// MsgType returns the integer uniquely identifying this message type on the