lnwire: refactor Encode to use specific writers - I

This commit takes 10 types of messages and refactors their Encode method
to use specific writers. The following commits will refactor the rest.
This commit is contained in:
yyforyongyu committed 2021-08-10 05:36:09 +08:00
1 parent f04410c546
commit 563ff7266a
10 files changed
+158 -58

No files matched your search

+9 -1
View File
@@ -33,7 +33,15 @@ var _ Message = (*FundingSigned)(nil)
//
// This is part of the lnwire.Message interface.
func (f *FundingSigned) Encode(w *bytes.Buffer, pver uint32) error {
return WriteElements(w, f.ChanID, f.CommitSig, f.ExtraData)
if err := WriteChannelID(w, f.ChanID); err != nil {
return err
}
if err := WriteSig(w, f.CommitSig); err != nil {
return err
}
return WriteBytes(w, f.ExtraData)
}
// Decode deserializes the serialized FundingSigned stored in the passed