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:
10 files changed
+158
-58
No files matched your search
@@ -66,13 +66,23 @@ func (a *AnnounceSignatures) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (a *AnnounceSignatures) Encode(w *bytes.Buffer, pver uint32) error {
|
||||
return WriteElements(w,
|
||||
a.ChannelID,
|
||||
a.ShortChannelID,
|
||||
a.NodeSignature,
|
||||
a.BitcoinSignature,
|
||||
a.ExtraOpaqueData,
|
||||
)
|
||||
if err := WriteChannelID(w, a.ChannelID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := WriteShortChannelID(w, a.ShortChannelID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := WriteSig(w, a.NodeSignature); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := WriteSig(w, a.BitcoinSignature); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return WriteBytes(w, a.ExtraOpaqueData)
|
||||
}
|
||||
|
||||
// MsgType returns the integer uniquely identifying this message type on the
|
||||
|
||||
Reference in new issue
Block a user