aboutsummaryrefslogtreecommitdiffstats
path: root/core/types/block.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-08-09 14:12:15 +0800
committerGitHub <noreply@github.com>2018-08-09 14:12:15 +0800
commitd28cc2c0cf87061fed9356509a28a307b9f55943 (patch)
tree09ac5ccd9ec721072f2c653e8201c1487e9e265c /core/types/block.go
parent7326f9722771633f3d137944c814544888a7a87f (diff)
downloaddexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar
dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.gz
dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.bz2
dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.lz
dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.xz
dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.zst
dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.zip
core: Add Block.IsGenesis() and set Block.ParentHash to 0 in genesis block. (#37)
Diffstat (limited to 'core/types/block.go')
-rw-r--r--core/types/block.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/core/types/block.go b/core/types/block.go
index 55e82da..e35ab8d 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -111,6 +111,11 @@ func (b *Block) Clone() *Block {
return bcopy
}
+// IsGenesis checks if the block is a genesisBlock
+func (b *Block) IsGenesis() bool {
+ return b.Height == 0 && b.ParentHash == common.Hash{}
+}
+
// ByHash is the helper type for sorting slice of blocks by hash.
type ByHash []*Block