accounts/abi: fix up error message and variable names

Signed-off-by: RJ Catalano <rj@monax.io>
This commit is contained in:
RJ Catalano 2017-06-14 08:34:56 -05:00
parent 1253f2cc58
commit cb853eb521
No known key found for this signature in database
GPG key ID: D4AB109D9B5D6386

View file

@ -160,19 +160,20 @@ func readInteger(kind reflect.Kind, b []byte) interface{} {
}
}
func getBoolValue(b []byte) (bool, error) {
for i, byte := range b {
if byte != 0 && i != 31 {
return false, fmt.Errorf("abi: Improperly encoded boolean value.")
func getBoolValue(word []byte) (bool, error) {
improperEncoding := "abi: improperly encoded boolean value"
for i, b := range word {
if b != 0 && i != 31 {
return false, fmt.Errorf(improperEncoding)
}
}
switch uint(b[31]) {
switch word[31] {
case 0:
return false, nil
case 1:
return true, nil
default:
return false, fmt.Errorf("abi: Improperly encoded boolean value.")
return false, fmt.Errorf(improperEncoding)
}
}