aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-30 20:55:21 +0800
committerobscuren <geffobscura@gmail.com>2015-04-30 20:55:21 +0800
commite4dba36892477f3ef614dd4e4f1234ae4a4e26d0 (patch)
tree27eef4ed49b85938557336508bea7bd55c612cea /core
parent28b39267d990352883df1c093fd6c36cd532cfdf (diff)
downloadgo-tangerine-e4dba36892477f3ef614dd4e4f1234ae4a4e26d0.tar.gz
go-tangerine-e4dba36892477f3ef614dd4e4f1234ae4a4e26d0.tar.zst
go-tangerine-e4dba36892477f3ef614dd4e4f1234ae4a4e26d0.zip
core: check for parent in calc TD. TD = (N != 0 == parent.TD) || (== D)
Diffstat (limited to 'core')
-rw-r--r--core/chain_manager.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index e97ed307c..9f62d3b47 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