diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-07-08 23:48:17 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-07-15 21:52:55 +0800 |
commit | a87089fd2dc08a69a4a4f1ef93db9a2871d819a3 (patch) | |
tree | b1634faefc24ee8b80b9ad9c06ac8df7f409558b /miner | |
parent | 1e24c2e4f428c85c2f83272af2696469cb8f5bed (diff) | |
download | dexon-a87089fd2dc08a69a4a4f1ef93db9a2871d819a3.tar dexon-a87089fd2dc08a69a4a4f1ef93db9a2871d819a3.tar.gz dexon-a87089fd2dc08a69a4a4f1ef93db9a2871d819a3.tar.bz2 dexon-a87089fd2dc08a69a4a4f1ef93db9a2871d819a3.tar.lz dexon-a87089fd2dc08a69a4a4f1ef93db9a2871d819a3.tar.xz dexon-a87089fd2dc08a69a4a4f1ef93db9a2871d819a3.tar.zst dexon-a87089fd2dc08a69a4a4f1ef93db9a2871d819a3.zip |
cmd, core, miner: add extradata validation to consensus rules
Diffstat (limited to 'miner')
-rw-r--r-- | miner/worker.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/miner/worker.go b/miner/worker.go index 7197a33ba..ba0085d52 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -17,6 +17,7 @@ package miner import ( + "bytes" "fmt" "math/big" "sync" @@ -469,12 +470,17 @@ func (self *worker) commitNewWork() { Extra: self.extra, Time: big.NewInt(tstamp), } - // If we are doing a DAO hard-fork check whether to override the extra-data or not + // 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 daoBlock.Cmp(header.Number) <= 0 && header.Number.Cmp(limit) < 0 { - header.Extra = common.CopyBytes(params.DAOForkBlockExtra) + // 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 |