lnwire: use write buffer in Encode methods

This commit changes the WriteElement and WriteElements methods to take a
write buffer instead of io.Writer. The corresponding Encode methods are
changed to use the write buffer.
This commit is contained in:
yyforyongyu
2021-06-17 14:17:30 +08:00
parent 879d3cc86c
commit aa1561c60d
36 changed files with 139 additions and 76 deletions

View File

@@ -1,6 +1,9 @@
package lnwire
import "io"
import (
"bytes"
"io"
)
// PongPayload is a set of opaque bytes sent in response to a ping message.
type PongPayload []byte
@@ -40,7 +43,7 @@ func (p *Pong) Decode(r io.Reader, pver uint32) error {
// protocol version specified.
//
// This is part of the lnwire.Message interface.
func (p *Pong) Encode(w io.Writer, pver uint32) error {
func (p *Pong) Encode(w *bytes.Buffer, pver uint32) error {
return WriteElements(w,
p.PongBytes,
)