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 committed 2021-08-10 05:36:08 +08:00
1 parent 879d3cc86c
commit aa1561c60d
36 files changed
+139 -76

No files matched your search

+5 -2
View File
@@ -1,6 +1,9 @@
package lnwire
import "io"
import (
"bytes"
"io"
)
// PingPayload is a set of opaque bytes used to pad out a ping message.
type PingPayload []byte
@@ -44,7 +47,7 @@ func (p *Ping) Decode(r io.Reader, pver uint32) error {
// protocol version specified.
//
// This is part of the lnwire.Message interface.
func (p *Ping) Encode(w io.Writer, pver uint32) error {
func (p *Ping) Encode(w *bytes.Buffer, pver uint32) error {
return WriteElements(w,
p.NumPongBytes,
p.PaddingBytes)