diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-07-16 18:08:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-16 18:08:16 +0800 |
commit | a4c4125b1155d9276614029163b498a17643f0f2 (patch) | |
tree | 328c438483cb7c87333190605ec1ef79cfa162a6 /miner | |
parent | aa1e052cb41c39363a9930added46dac5b6db832 (diff) | |
parent | 993b41216092fa6dc20d3755afe322cd1376b398 (diff) | |
download | dexon-a4c4125b1155d9276614029163b498a17643f0f2.tar dexon-a4c4125b1155d9276614029163b498a17643f0f2.tar.gz dexon-a4c4125b1155d9276614029163b498a17643f0f2.tar.bz2 dexon-a4c4125b1155d9276614029163b498a17643f0f2.tar.lz dexon-a4c4125b1155d9276614029163b498a17643f0f2.tar.xz dexon-a4c4125b1155d9276614029163b498a17643f0f2.tar.zst dexon-a4c4125b1155d9276614029163b498a17643f0f2.zip |
Merge pull request #2814 from karalabe/dao-hard-finalcombo
cmd, core, eth, miner, params, tests: finalize the DAO fork
Diffstat (limited to 'miner')
-rw-r--r-- | miner/worker.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/miner/worker.go b/miner/worker.go index 09cf6b6aa..dfda6d898 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -17,6 +17,7 @@ package miner import ( + "bytes" "fmt" "math/big" "sync" @@ -33,6 +34,7 @@ import ( "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/pow" "gopkg.in/fatih/set.v0" ) @@ -468,7 +470,19 @@ func (self *worker) commitNewWork() { Extra: self.extra, Time: big.NewInt(tstamp), } - + // If we are care about TheDAO hard-fork check whether to override the extra-data or not + if daoBlock := self.config.DAOForkBlock; daoBlock != nil { + // Check whether the block is among the fork extra-override range + limit := new(big.Int).Add(daoBlock, params.DAOForkExtraRange) + if header.Number.Cmp(daoBlock) >= 0 && header.Number.Cmp(limit) < 0 { + // Depending whether we support or oppose the fork, override differently + if self.config.DAOForkSupport { + header.Extra = common.CopyBytes(params.DAOForkBlockExtra) + } else if bytes.Compare(header.Extra, params.DAOForkBlockExtra) == 0 { + header.Extra = []byte{} // If miner opposes, don't let it use the reserved extra-data + } + } + } previous := self.current // Could potentially happen if starting to mine in an odd state. err := self.makeCurrent(parent, header) @@ -476,7 +490,11 @@ func (self *worker) commitNewWork() { glog.V(logger.Info).Infoln("Could not create new env for mining, retrying on next block.") return } + // Create the current work task and check any fork transitions needed work := self.current + if self.config.DAOForkSupport && self.config.DAOForkBlock != nil && self.config.DAOForkBlock.Cmp(header.Number) == 0 { + core.ApplyDAOHardFork(work.state) + } /* //approach 1 transactions := self.eth.TxPool().GetTransactions() |