accounts/abi: declare bool at the package level

Signed-off-by: RJ Catalano <rj@monax.io>
This commit is contained in:
RJ Catalano 2017-06-22 18:57:26 -05:00
parent 27defc9d43
commit 3afa23f2d5
No known key found for this signature in database
GPG key ID: D4AB109D9B5D6386
2 changed files with 7 additions and 3 deletions

View file

@ -21,6 +21,10 @@ import (
"reflect"
)
var (
errBadBool error = "abi: improperly encoded boolean value"
)
// formatSliceString formats the reflection kind with the given slice size
// and returns a formatted string representation.
func formatSliceString(kind reflect.Kind, sliceSize int) string {

View file

@ -164,10 +164,10 @@ func readBool(word []byte) (bool, error) {
if len(word) != 32 {
return false, fmt.Errorf("abi: fatal error: incorrect word length")
}
improperEncoding := "abi: improperly encoded boolean value"
for i, b := range word {
if b != 0 && i != 31 {
return false, fmt.Errorf(improperEncoding)
return false, errBadBool
}
}
switch word[31] {
@ -176,7 +176,7 @@ func readBool(word []byte) (bool, error) {
case 1:
return true, nil
default:
return false, fmt.Errorf(improperEncoding)
return false, errBadBool
}
}