aboutsummaryrefslogtreecommitdiffstats
path: root/core/chain_manager.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/chain_manager.go')
-rw-r--r--core/chain_manager.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index caa2e7b43..c68b7cfc2 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -23,12 +23,11 @@ type StateQuery interface {
func CalcDifficulty(block, parent *types.Block) *big.Int {
diff := new(big.Int)
- bh, ph := block.Header(), parent.Header()
- adjust := new(big.Int).Rsh(ph.Difficulty, 10)
- if bh.Time >= ph.Time+13 {
- diff.Sub(ph.Difficulty, adjust)
+ adjust := new(big.Int).Rsh(parent.Difficulty(), 10)
+ if block.Time() >= parent.Time()+8 {
+ diff.Sub(parent.Difficulty(), adjust)
} else {
- diff.Add(ph.Difficulty, adjust)
+ diff.Add(parent.Difficulty(), adjust)
}
return diff