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 committed 2021-08-10 05:36:09 +08:00
1 parent 563ff7266a
commit c1ad9cc60f
10 files changed
+213 -87

No files matched your search

+13 -6
View File
@@ -67,12 +67,19 @@ func (c *RevokeAndAck) Decode(r io.Reader, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (c *RevokeAndAck) Encode(w *bytes.Buffer, pver uint32) error {
return WriteElements(w,
c.ChanID,
c.Revocation[:],
c.NextRevocationKey,
c.ExtraData,
)
if err := WriteChannelID(w, c.ChanID); err != nil {
return err
}
if err := WriteBytes(w, c.Revocation[:]); err != nil {
return err
}
if err := WritePublicKey(w, c.NextRevocationKey); err != nil {
return err
}
return WriteBytes(w, c.ExtraData)
}
// MsgType returns the integer uniquely identifying this message type on the