mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 07:00:55 +02:00
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:
@@ -42,10 +42,19 @@ var _ Message = (*FundingCreated)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (f *FundingCreated) Encode(w *bytes.Buffer, pver uint32) error {
|
||||
return WriteElements(
|
||||
w, f.PendingChannelID[:], f.FundingPoint, f.CommitSig,
|
||||
f.ExtraData,
|
||||
)
|
||||
if err := WriteBytes(w, f.PendingChannelID[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := WriteOutPoint(w, f.FundingPoint); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := WriteSig(w, f.CommitSig); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return WriteBytes(w, f.ExtraData)
|
||||
}
|
||||
|
||||
// Decode deserializes the serialized FundingCreated stored in the passed
|
||||
|
Reference in New Issue
Block a user