mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 06:23:47 +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"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errBadBool error = "abi: improperly encoded boolean value"
|
||||||
|
)
|
||||||
|
|
||||||
// formatSliceString formats the reflection kind with the given slice size
|
// formatSliceString formats the reflection kind with the given slice size
|
||||||
// and returns a formatted string representation.
|
// and returns a formatted string representation.
|
||||||
func formatSliceString(kind reflect.Kind, sliceSize int) string {
|
func formatSliceString(kind reflect.Kind, sliceSize int) string {
|
||||||
|
|
|
||||||
|
|
@ -164,10 +164,10 @@ func readBool(word []byte) (bool, error) {
|
||||||
if len(word) != 32 {
|
if len(word) != 32 {
|
||||||
return false, fmt.Errorf("abi: fatal error: incorrect word length")
|
return false, fmt.Errorf("abi: fatal error: incorrect word length")
|
||||||
}
|
}
|
||||||
improperEncoding := "abi: improperly encoded boolean value"
|
|
||||||
for i, b := range word {
|
for i, b := range word {
|
||||||
if b != 0 && i != 31 {
|
if b != 0 && i != 31 {
|
||||||
return false, fmt.Errorf(improperEncoding)
|
return false, errBadBool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch word[31] {
|
switch word[31] {
|
||||||
|
|
@ -176,7 +176,7 @@ func readBool(word []byte) (bool, error) {
|
||||||
case 1:
|
case 1:
|
||||||
return true, nil
|
return true, nil
|
||||||
default:
|
default:
|
||||||
return false, fmt.Errorf(improperEncoding)
|
return false, errBadBool
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue