mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-07 13:55:17 +00:00
privval: migrate to protobuf (#4985)
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
var ErrOverflowInt32 = errors.New("int32 overflow")
|
||||
var ErrOverflowUint8 = errors.New("uint8 overflow")
|
||||
var ErrOverflowInt8 = errors.New("int8 overflow")
|
||||
|
||||
// SafeAddInt32 adds two int32 integers
|
||||
// If there is an overflow this will panic
|
||||
@@ -51,3 +52,14 @@ func SafeConvertUint8(a int64) (uint8, error) {
|
||||
}
|
||||
return uint8(a), nil
|
||||
}
|
||||
|
||||
// SafeConvertInt8 takes an int64 and checks if it overflows
|
||||
// If there is an overflow it returns an error
|
||||
func SafeConvertInt8(a int64) (int8, error) {
|
||||
if a > math.MaxInt8 {
|
||||
return 0, ErrOverflowInt8
|
||||
} else if a < math.MinInt8 {
|
||||
return 0, ErrOverflowInt8
|
||||
}
|
||||
return int8(a), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user