From 6253419ce542c5a2a3b46515a6e8def31dce1b98 Mon Sep 17 00:00:00 2001 From: Laura Cressman Date: Wed, 20 Sep 2017 20:42:18 -0400 Subject: [PATCH] channeldb: use binary.Read/Write in waitingproof.go Use binary.Read/Write when reading and writing booleans in Encode and Decode functions that operate on the WaitingProof struct. --- channeldb/waitingproof.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/channeldb/waitingproof.go b/channeldb/waitingproof.go index 083c131a..37fcc46a 100644 --- a/channeldb/waitingproof.go +++ b/channeldb/waitingproof.go @@ -207,12 +207,7 @@ func (p *WaitingProof) Key() WaitingProofKey { // Encode writes the internal representation of waiting proof in byte stream. func (p *WaitingProof) Encode(w io.Writer) error { - var b [1]byte - if p.isRemote { - b[0] = 1 - } - - if _, err := w.Write(b[:]); err != nil { + if err := binary.Write(w, byteOrder, p.isRemote); err != nil { return err } @@ -223,18 +218,13 @@ func (p *WaitingProof) Encode(w io.Writer) error { return nil } -// Decode reads the data from the byte stream and initialize the +// Decode reads the data from the byte stream and initializes the // waiting proof object with it. func (p *WaitingProof) Decode(r io.Reader) error { - var b [1]byte - if _, err := r.Read(b[:]); err != nil { + if err := binary.Read(r, byteOrder, &p.isRemote); err != nil { return err } - if b[0] == 1 { - (*p).isRemote = true - } - msg := &lnwire.AnnounceSignatures{} if err := msg.Decode(r, 0); err != nil { return err