From e4dba36892477f3ef614dd4e4f1234ae4a4e26d0 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 30 Apr 2015 14:55:21 +0200 Subject: [PATCH] core: check for parent in calc TD. TD = (N != 0 == parent.TD) || (== D) --- core/chain_manager.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/chain_manager.go b/core/chain_manager.go index e97ed307ce..9f62d3b47d 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -49,6 +49,10 @@ func CalcDifficulty(block, parent *types.Header) *big.Int { } func CalculateTD(block, parent *types.Block) *big.Int { + if parent == nil { + return block.Difficulty() + } + td := new(big.Int).Add(parent.Td, block.Header().Difficulty) return td