cmd/utils, mobile, params: use preset chain configs

This commit is contained in:
Péter Szilágyi 2016-11-15 23:39:27 +02:00
parent f803e046df
commit 42aa79790c
No known key found for this signature in database
GPG key ID: 119A76381CCB7DD2
4 changed files with 7 additions and 3 deletions

View file

@ -861,7 +861,6 @@ func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *params.ChainCon
(genesis.Hash() == params.MainNetGenesisHash && !ctx.GlobalBool(TestNetFlag.Name)) || (genesis.Hash() == params.MainNetGenesisHash && !ctx.GlobalBool(TestNetFlag.Name)) ||
(genesis.Hash() == params.TestNetGenesisHash && ctx.GlobalBool(TestNetFlag.Name)) (genesis.Hash() == params.TestNetGenesisHash && ctx.GlobalBool(TestNetFlag.Name))
// Set any missing chainConfig fields due to them being unset or system upgrade
if defaults { if defaults {
// Homestead fork // Homestead fork
if ctx.GlobalBool(TestNetFlag.Name) { if ctx.GlobalBool(TestNetFlag.Name) {
@ -896,7 +895,6 @@ func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *params.ChainCon
config.ChainId = params.MainNetChainID config.ChainId = params.MainNetChainID
} }
} }
// Force override any existing configs if explicitly requested // Force override any existing configs if explicitly requested
switch { switch {
case ctx.GlobalBool(SupportDAOFork.Name): case ctx.GlobalBool(SupportDAOFork.Name):

View file

@ -130,6 +130,7 @@ func NewNode(datadir string, config *NodeConfig) (*Node, error) {
if config.EthereumEnabled { if config.EthereumEnabled {
ethConf := &eth.Config{ ethConf := &eth.Config{
ChainConfig: &params.ChainConfig{ ChainConfig: &params.ChainConfig{
ChainId: big.NewInt(config.EthereumChainConfig.ChainID),
HomesteadBlock: big.NewInt(config.EthereumChainConfig.HomesteadBlock), HomesteadBlock: big.NewInt(config.EthereumChainConfig.HomesteadBlock),
DAOForkBlock: big.NewInt(config.EthereumChainConfig.DAOForkBlock), DAOForkBlock: big.NewInt(config.EthereumChainConfig.DAOForkBlock),
DAOForkSupport: config.EthereumChainConfig.DAOForkSupport, DAOForkSupport: config.EthereumChainConfig.DAOForkSupport,

View file

@ -27,6 +27,7 @@ import (
// MainnetChainConfig returns the chain configurations for the main Ethereum network. // MainnetChainConfig returns the chain configurations for the main Ethereum network.
func MainnetChainConfig() *ChainConfig { func MainnetChainConfig() *ChainConfig {
return &ChainConfig{ return &ChainConfig{
ChainID: params.MainNetChainID.Int64(),
HomesteadBlock: params.MainNetHomesteadBlock.Int64(), HomesteadBlock: params.MainNetHomesteadBlock.Int64(),
DAOForkBlock: params.MainNetDAOForkBlock.Int64(), DAOForkBlock: params.MainNetDAOForkBlock.Int64(),
DAOForkSupport: true, DAOForkSupport: true,
@ -46,9 +47,10 @@ func MainnetGenesis() string {
// TestnetChainConfig returns the chain configurations for the Ethereum test network. // TestnetChainConfig returns the chain configurations for the Ethereum test network.
func TestnetChainConfig() *ChainConfig { func TestnetChainConfig() *ChainConfig {
return &ChainConfig{ return &ChainConfig{
ChainID: params.TestNetChainID.Int64(),
HomesteadBlock: params.TestNetHomesteadBlock.Int64(), HomesteadBlock: params.TestNetHomesteadBlock.Int64(),
DAOForkBlock: 0, DAOForkBlock: 0,
DAOForkSupport: false, DAOForkSupport: true,
EIP150Block: params.TestNetHomesteadGasRepriceBlock.Int64(), EIP150Block: params.TestNetHomesteadGasRepriceBlock.Int64(),
EIP150Hash: Hash{params.TestNetHomesteadGasRepriceHash}, EIP150Hash: Hash{params.TestNetHomesteadGasRepriceHash},
EIP155Block: params.TestNetSpuriousDragon.Int64(), EIP155Block: params.TestNetSpuriousDragon.Int64(),
@ -63,6 +65,7 @@ func TestnetGenesis() string {
// ChainConfig is the core config which determines the blockchain settings. // ChainConfig is the core config which determines the blockchain settings.
type ChainConfig struct { type ChainConfig struct {
ChainID int64 // Chain ID for replay protection
HomesteadBlock int64 // Homestead switch block HomesteadBlock int64 // Homestead switch block
DAOForkBlock int64 // TheDAO hard-fork switch block DAOForkBlock int64 // TheDAO hard-fork switch block
DAOForkSupport bool // Whether the nodes supports or opposes the DAO hard-fork DAOForkSupport bool // Whether the nodes supports or opposes the DAO hard-fork

View file

@ -24,6 +24,7 @@ import (
// MainnetChainConfig is the chain parameters to run a node on the main network. // MainnetChainConfig is the chain parameters to run a node on the main network.
var MainnetChainConfig = &ChainConfig{ var MainnetChainConfig = &ChainConfig{
ChainId: MainNetChainID,
HomesteadBlock: MainNetHomesteadBlock, HomesteadBlock: MainNetHomesteadBlock,
DAOForkBlock: MainNetDAOForkBlock, DAOForkBlock: MainNetDAOForkBlock,
DAOForkSupport: true, DAOForkSupport: true,
@ -35,6 +36,7 @@ var MainnetChainConfig = &ChainConfig{
// TestnetChainConfig is the chain parameters to run a node on the test network. // TestnetChainConfig is the chain parameters to run a node on the test network.
var TestnetChainConfig = &ChainConfig{ var TestnetChainConfig = &ChainConfig{
ChainId: TestNetChainID,
HomesteadBlock: TestNetHomesteadBlock, HomesteadBlock: TestNetHomesteadBlock,
DAOForkBlock: TestNetDAOForkBlock, DAOForkBlock: TestNetDAOForkBlock,
DAOForkSupport: false, DAOForkSupport: false,