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

+13 -6
View File
@@ -59,12 +59,19 @@ func (g *GossipTimestampRange) Decode(r io.Reader, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (g *GossipTimestampRange) Encode(w *bytes.Buffer, pver uint32) error {
return WriteElements(w,
g.ChainHash[:],
g.FirstTimestamp,
g.TimestampRange,
g.ExtraData,
)
if err := WriteBytes(w, g.ChainHash[:]); err != nil {
return err
}
if err := WriteUint32(w, g.FirstTimestamp); err != nil {
return err
}
if err := WriteUint32(w, g.TimestampRange); err != nil {
return err
}
return WriteBytes(w, g.ExtraData)
}
// MsgType returns the integer uniquely identifying this message type on the