From 8339e133ee46bde5d3f9a41db5005a3c626440d8 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Fri, 14 Jul 2023 11:25:22 +0800 Subject: [PATCH] add function IsZero for type Hash --- common/types.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/types.go b/common/types.go index eea1201b11..72234a226b 100644 --- a/common/types.go +++ b/common/types.go @@ -73,6 +73,9 @@ func BigToHash(b *big.Int) Hash { return BytesToHash(b.Bytes()) } func Uint64ToHash(b uint64) Hash { return BytesToHash(new(big.Int).SetUint64(b).Bytes()) } func HexToHash(s string) Hash { return BytesToHash(FromHex(s)) } +// IsZero returns if a Hash is empty +func (h Hash) IsZero() bool { return h == Hash{} } + // Get the string representation of the underlying hash func (h Hash) Str() string { return string(h[:]) } func (h Hash) Bytes() []byte { return h[:] }