mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
added {Address,Hash}.IsZero()
This commit is contained in:
parent
35b2d07f4b
commit
f39dec1a8b
1 changed files with 13 additions and 0 deletions
|
|
@ -50,6 +50,9 @@ var (
|
||||||
|
|
||||||
// MaxHash represents the maximum possible hash value.
|
// MaxHash represents the maximum possible hash value.
|
||||||
MaxHash = HexToHash("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
MaxHash = HexToHash("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
||||||
|
|
||||||
|
addr0 Address // zero Address
|
||||||
|
hash0 Hash // zero Hash
|
||||||
)
|
)
|
||||||
|
|
||||||
// Hash represents the 32 byte Keccak256 hash of arbitrary data.
|
// Hash represents the 32 byte Keccak256 hash of arbitrary data.
|
||||||
|
|
@ -194,6 +197,11 @@ func (h *Hash) UnmarshalGraphQL(input interface{}) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsZero returns true for the zero hash.
|
||||||
|
func (h Hash) IsZero() bool {
|
||||||
|
return h == hash0
|
||||||
|
}
|
||||||
|
|
||||||
// UnprefixedHash allows marshaling a Hash without 0x prefix.
|
// UnprefixedHash allows marshaling a Hash without 0x prefix.
|
||||||
type UnprefixedHash Hash
|
type UnprefixedHash Hash
|
||||||
|
|
||||||
|
|
@ -371,6 +379,11 @@ func (a *Address) UnmarshalGraphQL(input interface{}) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsZero returns true for the zero address.
|
||||||
|
func (a Address) IsZero() bool {
|
||||||
|
return a == addr0
|
||||||
|
}
|
||||||
|
|
||||||
// UnprefixedAddress allows marshaling an Address without 0x prefix.
|
// UnprefixedAddress allows marshaling an Address without 0x prefix.
|
||||||
type UnprefixedAddress Address
|
type UnprefixedAddress Address
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue