diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-08-09 14:12:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-09 14:12:15 +0800 |
commit | d28cc2c0cf87061fed9356509a28a307b9f55943 (patch) | |
tree | 09ac5ccd9ec721072f2c653e8201c1487e9e265c /core/types/block.go | |
parent | 7326f9722771633f3d137944c814544888a7a87f (diff) | |
download | tangerine-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar tangerine-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.gz tangerine-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.bz2 tangerine-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.lz tangerine-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.xz tangerine-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.zst tangerine-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.go | 5 |
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 |