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.
This commit is contained in:
Dave Collins 2013-05-09 15:23:31 -05:00
parent 4c160efc96
commit 970b9c129d

View file

@ -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]