mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
cmd, core: merge flags testnet and apothem
This commit is contained in:
parent
020e9aa81d
commit
1d653e57ab
5 changed files with 14 additions and 27 deletions
|
|
@ -45,7 +45,7 @@ var (
|
||||||
utils.DataDirFlag,
|
utils.DataDirFlag,
|
||||||
utils.XDCXDataDirFlag,
|
utils.XDCXDataDirFlag,
|
||||||
utils.LightModeFlag,
|
utils.LightModeFlag,
|
||||||
utils.XDCTestnetFlag,
|
utils.TestnetFlag,
|
||||||
},
|
},
|
||||||
Description: `
|
Description: `
|
||||||
The init command initializes a new genesis block and definition for the network.
|
The init command initializes a new genesis block and definition for the network.
|
||||||
|
|
@ -156,9 +156,9 @@ Use "ethereum dump 0" to dump the genesis block.`,
|
||||||
func initGenesis(ctx *cli.Context) error {
|
func initGenesis(ctx *cli.Context) error {
|
||||||
var err error
|
var err error
|
||||||
genesis := new(core.Genesis)
|
genesis := new(core.Genesis)
|
||||||
if ctx.Bool(utils.XDCTestnetFlag.Name) {
|
if ctx.Bool(utils.TestnetFlag.Name) {
|
||||||
if ctx.Args().Len() > 0 {
|
if ctx.Args().Len() > 0 {
|
||||||
utils.Fatalf("Flags --apothem and genesis file can't be used at the same time")
|
utils.Fatalf("The testnet flag and genesis file can't be used at the same time")
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(xdc_genesis.TestnetGenesis, &genesis)
|
err = json.Unmarshal(xdc_genesis.TestnetGenesis, &genesis)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -168,7 +168,7 @@ func initGenesis(ctx *cli.Context) error {
|
||||||
genesisPath := ctx.Args().First()
|
genesisPath := ctx.Args().First()
|
||||||
if genesisPath == "mainnet" {
|
if genesisPath == "mainnet" {
|
||||||
err = json.Unmarshal(xdc_genesis.MainnetGenesis, &genesis)
|
err = json.Unmarshal(xdc_genesis.MainnetGenesis, &genesis)
|
||||||
} else if genesisPath == "testnet" {
|
} else if genesisPath == "testnet" || genesisPath == "apothem" {
|
||||||
err = json.Unmarshal(xdc_genesis.TestnetGenesis, &genesis)
|
err = json.Unmarshal(xdc_genesis.TestnetGenesis, &genesis)
|
||||||
} else if genesisPath == "devnet" {
|
} else if genesisPath == "devnet" {
|
||||||
err = json.Unmarshal(xdc_genesis.DevnetGenesis, &genesis)
|
err = json.Unmarshal(xdc_genesis.DevnetGenesis, &genesis)
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check testnet is enable.
|
// Check testnet is enable.
|
||||||
if ctx.Bool(utils.XDCTestnetFlag.Name) {
|
if ctx.Bool(utils.TestnetFlag.Name) {
|
||||||
common.IsTestnet = true
|
common.IsTestnet = true
|
||||||
common.TRC21IssuerSMC = common.TRC21IssuerSMCTestNet
|
common.TRC21IssuerSMC = common.TRC21IssuerSMCTestNet
|
||||||
cfg.Eth.NetworkId = 51
|
cfg.Eth.NetworkId = 51
|
||||||
|
|
|
||||||
|
|
@ -117,10 +117,9 @@ var (
|
||||||
utils.NodeKeyHexFlag,
|
utils.NodeKeyHexFlag,
|
||||||
//utils.DeveloperFlag,
|
//utils.DeveloperFlag,
|
||||||
//utils.DeveloperPeriodFlag,
|
//utils.DeveloperPeriodFlag,
|
||||||
//utils.TestnetFlag,
|
utils.TestnetFlag,
|
||||||
//utils.RinkebyFlag,
|
//utils.RinkebyFlag,
|
||||||
//utils.VMEnableDebugFlag,
|
//utils.VMEnableDebugFlag,
|
||||||
utils.XDCTestnetFlag,
|
|
||||||
utils.Enable0xPrefixFlag,
|
utils.Enable0xPrefixFlag,
|
||||||
utils.EnableXDCPrefixFlag,
|
utils.EnableXDCPrefixFlag,
|
||||||
utils.RewoundFlag,
|
utils.RewoundFlag,
|
||||||
|
|
|
||||||
|
|
@ -106,12 +106,8 @@ var (
|
||||||
}
|
}
|
||||||
TestnetFlag = &cli.BoolFlag{
|
TestnetFlag = &cli.BoolFlag{
|
||||||
Name: "testnet",
|
Name: "testnet",
|
||||||
Usage: "Ropsten network: pre-configured proof-of-work test network",
|
Aliases: []string{"apothem"},
|
||||||
Category: flags.EthCategory,
|
Usage: "XDC apothem network",
|
||||||
}
|
|
||||||
XDCTestnetFlag = &cli.BoolFlag{
|
|
||||||
Name: "apothem",
|
|
||||||
Usage: "XDC Apothem Network",
|
|
||||||
Category: flags.EthCategory,
|
Category: flags.EthCategory,
|
||||||
}
|
}
|
||||||
RinkebyFlag = &cli.BoolFlag{
|
RinkebyFlag = &cli.BoolFlag{
|
||||||
|
|
@ -883,14 +879,11 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
|
||||||
if cfg.BootstrapNodes != nil {
|
if cfg.BootstrapNodes != nil {
|
||||||
return // Already set by config file, don't apply defaults.
|
return // Already set by config file, don't apply defaults.
|
||||||
}
|
}
|
||||||
networkID := uint64(0)
|
networkID := ctx.Uint64(NetworkIdFlag.Name)
|
||||||
if ctx.IsSet(NetworkIdFlag.Name) {
|
|
||||||
networkID = ctx.Uint64(NetworkIdFlag.Name)
|
|
||||||
}
|
|
||||||
switch {
|
switch {
|
||||||
case ctx.Bool(XDCTestnetFlag.Name) || networkID == params.TestnetChainConfig.ChainId.Uint64():
|
case ctx.Bool(TestnetFlag.Name) || networkID == 51:
|
||||||
urls = params.TestnetBootnodes
|
urls = params.TestnetBootnodes
|
||||||
case networkID == params.DevnetChainConfig.ChainId.Uint64():
|
case networkID == 551:
|
||||||
urls = params.DevnetBootnodes
|
urls = params.DevnetBootnodes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -921,7 +914,7 @@ func setBootstrapNodesV5(ctx *cli.Context, cfg *p2p.Config) {
|
||||||
urls = SplitAndTrim(ctx.String(BootnodesFlag.Name))
|
urls = SplitAndTrim(ctx.String(BootnodesFlag.Name))
|
||||||
case ctx.IsSet(BootnodesV5Flag.Name):
|
case ctx.IsSet(BootnodesV5Flag.Name):
|
||||||
urls = SplitAndTrim(ctx.String(BootnodesV5Flag.Name))
|
urls = SplitAndTrim(ctx.String(BootnodesV5Flag.Name))
|
||||||
case ctx.Bool(XDCTestnetFlag.Name):
|
case ctx.Bool(TestnetFlag.Name):
|
||||||
urls = params.TestnetBootnodes
|
urls = params.TestnetBootnodes
|
||||||
case cfg.BootstrapNodesV5 != nil:
|
case cfg.BootstrapNodesV5 != nil:
|
||||||
return // already set, don't apply defaults.
|
return // already set, don't apply defaults.
|
||||||
|
|
@ -1443,9 +1436,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
||||||
if ctx.IsSet(NetworkIdFlag.Name) {
|
if ctx.IsSet(NetworkIdFlag.Name) {
|
||||||
cfg.NetworkId = ctx.Uint64(NetworkIdFlag.Name)
|
cfg.NetworkId = ctx.Uint64(NetworkIdFlag.Name)
|
||||||
}
|
}
|
||||||
if ctx.Bool(XDCTestnetFlag.Name) {
|
|
||||||
cfg.NetworkId = 51
|
|
||||||
}
|
|
||||||
|
|
||||||
if ctx.IsSet(CacheFlag.Name) || ctx.IsSet(CacheDatabaseFlag.Name) {
|
if ctx.IsSet(CacheFlag.Name) || ctx.IsSet(CacheDatabaseFlag.Name) {
|
||||||
cfg.DatabaseCache = ctx.Int(CacheFlag.Name) * ctx.Int(CacheDatabaseFlag.Name) / 100
|
cfg.DatabaseCache = ctx.Int(CacheFlag.Name) * ctx.Int(CacheDatabaseFlag.Name) / 100
|
||||||
|
|
@ -1501,7 +1491,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
||||||
switch {
|
switch {
|
||||||
case ctx.Bool(TestnetFlag.Name):
|
case ctx.Bool(TestnetFlag.Name):
|
||||||
if !ctx.IsSet(NetworkIdFlag.Name) {
|
if !ctx.IsSet(NetworkIdFlag.Name) {
|
||||||
cfg.NetworkId = 3
|
cfg.NetworkId = 51
|
||||||
}
|
}
|
||||||
cfg.Genesis = core.DefaultTestnetGenesisBlock()
|
cfg.Genesis = core.DefaultTestnetGenesisBlock()
|
||||||
case ctx.Bool(RinkebyFlag.Name):
|
case ctx.Bool(RinkebyFlag.Name):
|
||||||
|
|
|
||||||
|
|
@ -281,10 +281,8 @@ func DefaultGenesisBlock() *Genesis {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultTestnetGenesisBlock returns the Ropsten network genesis block.
|
// DefaultTestnetGenesisBlock returns the XDC testnet genesis block.
|
||||||
func DefaultTestnetGenesisBlock() *Genesis {
|
func DefaultTestnetGenesisBlock() *Genesis {
|
||||||
config := params.TestnetChainConfig
|
|
||||||
config.XDPoS.V2 = nil
|
|
||||||
return &Genesis{
|
return &Genesis{
|
||||||
Config: params.TestnetChainConfig,
|
Config: params.TestnetChainConfig,
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue