From 970b9c129d932a24be2691d993ab2c655c72dfc7 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Thu, 9 May 2013 15:23:31 -0500 Subject: [PATCH] Remove dead error check. The io.ReadFull function always returns an error if the full payload can't be read, so there is no reason to further check if the payload length matches after a successful read. --- message.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/message.go b/message.go index 5d186d3b..8e107f1b 100644 --- a/message.go +++ b/message.go @@ -117,7 +117,7 @@ type messageHeader struct { checksum [4]byte // 4 bytes } -// readMessageHeader reads a bitcoin messager header from r. +// readMessageHeader reads a bitcoin message header from r. func readMessageHeader(r io.Reader) (*messageHeader, error) { var command [commandSize]byte @@ -195,15 +195,10 @@ func readMessage(r io.Reader, pver uint32, hdr *messageHeader) (Message, []byte, // Read payload. payload := make([]byte, hdr.length) - n, err := io.ReadFull(r, payload) + _, err = io.ReadFull(r, payload) if err != nil { return nil, nil, err } - if uint32(n) != hdr.length { - str := "readMessage: failed to read payload - Read %v " + - "bytes, but payload size is %v bytes." - return nil, nil, fmt.Errorf(str, n, hdr.length) - } // Test checksum. checksum := DoubleSha256(payload)[0:4]