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:
parent
4c160efc96
commit
970b9c129d
1 changed files with 2 additions and 7 deletions
|
@ -117,7 +117,7 @@ type messageHeader struct {
|
||||||
checksum [4]byte // 4 bytes
|
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) {
|
func readMessageHeader(r io.Reader) (*messageHeader, error) {
|
||||||
var command [commandSize]byte
|
var command [commandSize]byte
|
||||||
|
|
||||||
|
@ -195,15 +195,10 @@ func readMessage(r io.Reader, pver uint32, hdr *messageHeader) (Message, []byte,
|
||||||
|
|
||||||
// Read payload.
|
// Read payload.
|
||||||
payload := make([]byte, hdr.length)
|
payload := make([]byte, hdr.length)
|
||||||
n, err := io.ReadFull(r, payload)
|
_, err = io.ReadFull(r, payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
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.
|
// Test checksum.
|
||||||
checksum := DoubleSha256(payload)[0:4]
|
checksum := DoubleSha256(payload)[0:4]
|
||||||
|
|
Loading…
Reference in a new issue