cmd, core, miner: add extradata validation to consensus rules
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user