File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ var customGenesisTests = []struct {
7575 "timestamp" : "0x00",
7676 "config" : {
7777 "homesteadBlock" : 314,
78+ "daoForkBlock" : 141
7879 },
7980 }` ,
8081 query : "eth.getBlock(0).nonce" ,
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import (
3333 "github.com/ethereum/go-ethereum/event"
3434 "github.com/ethereum/go-ethereum/logger"
3535 "github.com/ethereum/go-ethereum/logger/glog"
36+ "github.com/ethereum/go-ethereum/params"
3637 "github.com/ethereum/go-ethereum/pow"
3738 "gopkg.in/fatih/set.v0"
3839)
@@ -468,7 +469,14 @@ func (self *worker) commitNewWork() {
468469 Extra : self .extra ,
469470 Time : big .NewInt (tstamp ),
470471 }
471-
472+ // If we are doing a DAO hard-fork check whether to override the extra-data or not
473+ if daoBlock := self .config .DAOForkBlock ; daoBlock != nil {
474+ // Check whether the block is among the fork extra-override range
475+ limit := new (big.Int ).Add (daoBlock , params .DAOForkExtraRange )
476+ if daoBlock .Cmp (header .Number ) <= 0 && header .Number .Cmp (limit ) < 0 {
477+ header .Extra = common .CopyBytes (params .DAOForkBlockExtra )
478+ }
479+ }
472480 previous := self .current
473481 // Could potentially happen if starting to mine in an odd state.
474482 err := self .makeCurrent (parent , header )
Original file line number Diff line number Diff line change 1616
1717package params
1818
19- import "math/big"
19+ import (
20+ "math/big"
21+
22+ "github.com/ethereum/go-ethereum/common"
23+ )
2024
2125var (
22- TestNetHomesteadBlock = big .NewInt (494000 ) // testnet homestead block
23- MainNetHomesteadBlock = big .NewInt (1150000 ) // mainnet homestead block
24- TestNetDAOForkBlock = big .NewInt (8888888 ) // testnet dao hard-fork block
25- MainNetDAOForkBlock = big .NewInt (9999999 ) // mainnet dao hard-fork block
26+ TestNetHomesteadBlock = big .NewInt (494000 ) // Testnet homestead block
27+ MainNetHomesteadBlock = big .NewInt (1150000 ) // Mainnet homestead block
28+
29+ TestNetDAOForkBlock = big .NewInt (8888888 ) // Testnet dao hard-fork block
30+ MainNetDAOForkBlock = big .NewInt (9999999 ) // Mainnet dao hard-fork block
31+ DAOForkBlockExtra = common .FromHex ("0x64616f2d686172642d666f726b" ) // Block extradata to signel the fork with ("dao-hard-fork")
32+ DAOForkExtraRange = big .NewInt (10 ) // Number of blocks to override the extradata (prevent no-fork attacks)
2633)
You can’t perform that action at this time.
0 commit comments