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:
36 files changed
+139
-76
No files matched your search
@@ -2,6 +2,7 @@ package channeldb
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"io"
|
||||
@@ -232,7 +233,14 @@ func (p *WaitingProof) Encode(w io.Writer) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := p.AnnounceSignatures.Encode(w, 0); err != nil {
|
||||
// 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")
|
||||
}
|
||||
|
||||
if err := p.AnnounceSignatures.Encode(buf, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user