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.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 6212fb842..f2382cf8d 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -28,16 +28,16 @@ type StateQuery interface {
GetAccount(addr []byte) *state.StateObject
}
-func CalcDifficulty(block, parent *types.Block) *big.Int {
+func CalcDifficulty(block, parent *types.Header) *big.Int {
diff := new(big.Int)
//adjust := new(big.Int).Rsh(parent.Difficulty(), 10)
//if block.Time() >= parent.Time()+8 {
- adjust := new(big.Int).Div(parent.Difficulty(), big.NewInt(2048))
- if (block.Time() - parent.Time()) < 8 {
- diff.Add(parent.Difficulty(), adjust)
+ adjust := new(big.Int).Div(parent.Difficulty, big.NewInt(2048))
+ if (block.Time - parent.Time) < 8 {
+ diff.Add(parent.Difficulty, adjust)
} else {
- diff.Sub(parent.Difficulty(), adjust)
+ diff.Sub(parent.Difficulty, adjust)
}
return diff
@@ -206,7 +206,7 @@ func (bc *ChainManager) NewBlock(coinbase []byte) *types.Block {
parent := bc.currentBlock
if parent != nil {
header := block.Header()
- header.Difficulty = CalcDifficulty(block, parent)
+ header.Difficulty = CalcDifficulty(block.Header(), parent.Header())
header.Number = new(big.Int).Add(parent.Header().Number, ethutil.Big1)
header.GasLimit = CalcGasLimit(parent, block)