mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-23 17:51:39 +00:00
architecting peer
This commit is contained in:
@ -40,3 +40,11 @@ func ReadByteSlice(r io.Reader) ByteSlice {
|
||||
if err != nil { panic(err) }
|
||||
return ByteSlice(bytes)
|
||||
}
|
||||
|
||||
func ReadByteSliceSafe(r io.Reader) (ByteSlice, error) {
|
||||
length := int(ReadUInt32(r))
|
||||
bytes := make([]byte, length)
|
||||
_, err := io.ReadFull(r, bytes)
|
||||
if err != nil { return nil, err }
|
||||
return ByteSlice(bytes), nil
|
||||
}
|
||||
|
@ -48,6 +48,13 @@ func ReadByte(r io.Reader) Byte {
|
||||
return Byte(buf[0])
|
||||
}
|
||||
|
||||
func ReadByteSafe(r io.Reader) (Byte, error) {
|
||||
buf := [1]byte{0}
|
||||
_, err := io.ReadFull(r, buf[:])
|
||||
if err != nil { return Byte(0), err }
|
||||
return Byte(buf[0]), nil
|
||||
}
|
||||
|
||||
|
||||
// Int8
|
||||
|
||||
|
Reference in New Issue
Block a user