Unverified Commit 4714ce94 authored by Marius van der Wijden's avatar Marius van der Wijden Committed by GitHub

cmd/geth: added --mainnet flag (#21932)

* cmd/geth: added --mainnet flag

* cmd/utils: set default genesis if --mainnet is specified

* cmd/utils: addressed comments
parent eb2a1dfd
...@@ -159,6 +159,7 @@ The export-preimages command export hash preimages to an RLP encoded stream`, ...@@ -159,6 +159,7 @@ The export-preimages command export hash preimages to an RLP encoded stream`,
utils.CacheFlag, utils.CacheFlag,
utils.SyncModeFlag, utils.SyncModeFlag,
utils.FakePoWFlag, utils.FakePoWFlag,
utils.MainnetFlag,
utils.RopstenFlag, utils.RopstenFlag,
utils.RinkebyFlag, utils.RinkebyFlag,
utils.TxLookupLimitFlag, utils.TxLookupLimitFlag,
...@@ -210,6 +211,7 @@ Use "ethereum dump 0" to dump the genesis block.`, ...@@ -210,6 +211,7 @@ Use "ethereum dump 0" to dump the genesis block.`,
utils.DataDirFlag, utils.DataDirFlag,
utils.AncientFlag, utils.AncientFlag,
utils.CacheFlag, utils.CacheFlag,
utils.MainnetFlag,
utils.RopstenFlag, utils.RopstenFlag,
utils.RinkebyFlag, utils.RinkebyFlag,
utils.GoerliFlag, utils.GoerliFlag,
......
...@@ -140,6 +140,7 @@ var ( ...@@ -140,6 +140,7 @@ var (
utils.NodeKeyFileFlag, utils.NodeKeyFileFlag,
utils.NodeKeyHexFlag, utils.NodeKeyHexFlag,
utils.DNSDiscoveryFlag, utils.DNSDiscoveryFlag,
utils.MainnetFlag,
utils.DeveloperFlag, utils.DeveloperFlag,
utils.DeveloperPeriodFlag, utils.DeveloperPeriodFlag,
utils.LegacyTestnetFlag, utils.LegacyTestnetFlag,
......
...@@ -40,6 +40,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{ ...@@ -40,6 +40,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.USBFlag, utils.USBFlag,
utils.SmartCardDaemonPathFlag, utils.SmartCardDaemonPathFlag,
utils.NetworkIdFlag, utils.NetworkIdFlag,
utils.MainnetFlag,
utils.GoerliFlag, utils.GoerliFlag,
utils.RinkebyFlag, utils.RinkebyFlag,
utils.YoloV2Flag, utils.YoloV2Flag,
......
...@@ -135,6 +135,10 @@ var ( ...@@ -135,6 +135,10 @@ var (
Usage: "Explicitly set network id (integer)(For testnets: use --ropsten, --rinkeby, --goerli instead)", Usage: "Explicitly set network id (integer)(For testnets: use --ropsten, --rinkeby, --goerli instead)",
Value: eth.DefaultConfig.NetworkId, Value: eth.DefaultConfig.NetworkId,
} }
MainnetFlag = cli.BoolFlag{
Name: "mainnet",
Usage: "Ethereum mainnet",
}
GoerliFlag = cli.BoolFlag{ GoerliFlag = cli.BoolFlag{
Name: "goerli", Name: "goerli",
Usage: "Görli network: pre-configured proof-of-authority test network", Usage: "Görli network: pre-configured proof-of-authority test network",
...@@ -1494,7 +1498,7 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node) { ...@@ -1494,7 +1498,7 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node) {
// SetEthConfig applies eth-related command line flags to the config. // SetEthConfig applies eth-related command line flags to the config.
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
// Avoid conflicting network flags // Avoid conflicting network flags
CheckExclusive(ctx, DeveloperFlag, LegacyTestnetFlag, RopstenFlag, RinkebyFlag, GoerliFlag, YoloV2Flag) CheckExclusive(ctx, MainnetFlag, DeveloperFlag, LegacyTestnetFlag, RopstenFlag, RinkebyFlag, GoerliFlag, YoloV2Flag)
CheckExclusive(ctx, LegacyLightServFlag, LightServeFlag, SyncModeFlag, "light") CheckExclusive(ctx, LegacyLightServFlag, LightServeFlag, SyncModeFlag, "light")
CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer
CheckExclusive(ctx, GCModeFlag, "archive", TxLookupLimitFlag) CheckExclusive(ctx, GCModeFlag, "archive", TxLookupLimitFlag)
...@@ -1608,6 +1612,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { ...@@ -1608,6 +1612,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
} }
// Override any default configs for hard coded networks. // Override any default configs for hard coded networks.
switch { switch {
case ctx.GlobalBool(MainnetFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1
}
cfg.Genesis = core.DefaultGenesisBlock()
SetDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash)
case ctx.GlobalBool(LegacyTestnetFlag.Name) || ctx.GlobalBool(RopstenFlag.Name): case ctx.GlobalBool(LegacyTestnetFlag.Name) || ctx.GlobalBool(RopstenFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) { if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 3 cfg.NetworkId = 3
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment