mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-01 22:57:42 +02:00
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:
@@ -265,8 +265,15 @@ func (s *Single) Serialize(w io.Writer) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO(yy): remove the type assertion when we finished refactoring db
|
||||
// into using write buffer.
|
||||
buf, ok := w.(*bytes.Buffer)
|
||||
if !ok {
|
||||
return fmt.Errorf("expect io.Writer to be *bytes.Buffer")
|
||||
}
|
||||
|
||||
return lnwire.WriteElements(
|
||||
w,
|
||||
buf,
|
||||
byte(s.Version),
|
||||
uint16(len(singleBytes.Bytes())),
|
||||
singleBytes.Bytes(),
|
||||
|
Reference in New Issue
Block a user