mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
accounts/abi: declare bool at the package level
Signed-off-by: RJ Catalano <rj@monax.io>
This commit is contained in:
parent
27defc9d43
commit
3afa23f2d5
2 changed files with 7 additions and 3 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue