peer_protocol/int.go | 10 +++++----- diff --git a/peer_protocol/int.go b/peer_protocol/int.go index 80fb6624d7bcd3ef148141ec5885a663f6950699..13bd1ca9c2027e6449a9b07d15b1a70bb2b8d791 100644 --- a/peer_protocol/int.go +++ b/peer_protocol/int.go @@ -19,12 +19,12 @@ } func (i *Integer) Read(r io.Reader) error { var b [4]byte - n, err := r.Read(b[:]) - if n == 4 { - return i.UnmarshalBinary(b[:]) - } + n, err := io.ReadFull(r, b[:]) if err == nil { - return io.ErrUnexpectedEOF + if n != 4 { + panic(n) + } + return i.UnmarshalBinary(b[:]) } return err }