aboutsummaryrefslogtreecommitdiffstats
path: root/core/chain_manager.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-04 17:49:56 +0800
committerobscuren <geffobscura@gmail.com>2015-03-04 17:49:56 +0800
commit84a4f761f332b4aecc36c748bc4c9a4ce1c114e2 (patch)
tree5966338284ded703d77b4dba66b9876f64202963 /core/chain_manager.go
parentd4d505c868fcd0f692ec3573bd6cfcb1c5230fe2 (diff)
downloaddexon-84a4f761f332b4aecc36c748bc4c9a4ce1c114e2.tar
dexon-84a4f761f332b4aecc36c748bc4c9a4ce1c114e2.tar.gz
dexon-84a4f761f332b4aecc36c748bc4c9a4ce1c114e2.tar.bz2
dexon-84a4f761f332b4aecc36c748bc4c9a4ce1c114e2.tar.lz
dexon-84a4f761f332b4aecc36c748bc4c9a4ce1c114e2.tar.xz
dexon-84a4f761f332b4aecc36c748bc4c9a4ce1c114e2.tar.zst
dexon-84a4f761f332b4aecc36c748bc4c9a4ce1c114e2.zip
uncle validation
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)