mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/utils: make goerli the default testnet
This commit is contained in:
parent
1e2e1b41f8
commit
61ad875821
1 changed files with 21 additions and 17 deletions
|
|
@ -162,11 +162,15 @@ var (
|
||||||
}
|
}
|
||||||
NetworkIdFlag = cli.Uint64Flag{
|
NetworkIdFlag = cli.Uint64Flag{
|
||||||
Name: "networkid",
|
Name: "networkid",
|
||||||
Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby)",
|
Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby, 5=Görli)",
|
||||||
Value: eth.DefaultConfig.NetworkId,
|
Value: eth.DefaultConfig.NetworkId,
|
||||||
}
|
}
|
||||||
TestnetFlag = cli.BoolFlag{
|
TestnetFlag = cli.BoolFlag{
|
||||||
Name: "testnet",
|
Name: "testnet",
|
||||||
|
Usage: "Görli network: pre-configured proof-of-authority test network",
|
||||||
|
}
|
||||||
|
RopstenFlag = cli.BoolFlag{
|
||||||
|
Name: "ropsten",
|
||||||
Usage: "Ropsten network: pre-configured proof-of-work test network",
|
Usage: "Ropsten network: pre-configured proof-of-work test network",
|
||||||
}
|
}
|
||||||
RinkebyFlag = cli.BoolFlag{
|
RinkebyFlag = cli.BoolFlag{
|
||||||
|
|
@ -774,16 +778,16 @@ var (
|
||||||
|
|
||||||
// MakeDataDir retrieves the currently requested data directory, terminating
|
// MakeDataDir retrieves the currently requested data directory, terminating
|
||||||
// if none (or the empty string) is specified. If the node is starting a testnet,
|
// if none (or the empty string) is specified. If the node is starting a testnet,
|
||||||
// the a subdirectory of the specified datadir will be used.
|
// then a subdirectory of the specified data-dir will be used.
|
||||||
func MakeDataDir(ctx *cli.Context) string {
|
func MakeDataDir(ctx *cli.Context) string {
|
||||||
if path := ctx.GlobalString(DataDirFlag.Name); path != "" {
|
if path := ctx.GlobalString(DataDirFlag.Name); path != "" {
|
||||||
if ctx.GlobalBool(TestnetFlag.Name) {
|
if ctx.GlobalBool(RopstenFlag.Name) {
|
||||||
return filepath.Join(path, "testnet")
|
return filepath.Join(path, "testnet")
|
||||||
}
|
}
|
||||||
if ctx.GlobalBool(RinkebyFlag.Name) {
|
if ctx.GlobalBool(RinkebyFlag.Name) {
|
||||||
return filepath.Join(path, "rinkeby")
|
return filepath.Join(path, "rinkeby")
|
||||||
}
|
}
|
||||||
if ctx.GlobalBool(GoerliFlag.Name) {
|
if ctx.GlobalBool(TestnetFlag.Name) || ctx.GlobalBool(GoerliFlag.Name) {
|
||||||
return filepath.Join(path, "goerli")
|
return filepath.Join(path, "goerli")
|
||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
|
|
@ -836,11 +840,11 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
|
||||||
} else {
|
} else {
|
||||||
urls = splitAndTrim(ctx.GlobalString(BootnodesFlag.Name))
|
urls = splitAndTrim(ctx.GlobalString(BootnodesFlag.Name))
|
||||||
}
|
}
|
||||||
case ctx.GlobalBool(TestnetFlag.Name):
|
case ctx.GlobalBool(RopstenFlag.Name):
|
||||||
urls = params.TestnetBootnodes
|
urls = params.RopstenBootnodes
|
||||||
case ctx.GlobalBool(RinkebyFlag.Name):
|
case ctx.GlobalBool(RinkebyFlag.Name):
|
||||||
urls = params.RinkebyBootnodes
|
urls = params.RinkebyBootnodes
|
||||||
case ctx.GlobalBool(GoerliFlag.Name):
|
case ctx.GlobalBool(TestnetFlag.Name) || ctx.GlobalBool(GoerliFlag.Name):
|
||||||
urls = params.GoerliBootnodes
|
urls = params.GoerliBootnodes
|
||||||
case cfg.BootstrapNodes != nil:
|
case cfg.BootstrapNodes != nil:
|
||||||
return // already set, don't apply defaults.
|
return // already set, don't apply defaults.
|
||||||
|
|
@ -1240,11 +1244,11 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) {
|
||||||
cfg.DataDir = ctx.GlobalString(DataDirFlag.Name)
|
cfg.DataDir = ctx.GlobalString(DataDirFlag.Name)
|
||||||
case ctx.GlobalBool(DeveloperFlag.Name):
|
case ctx.GlobalBool(DeveloperFlag.Name):
|
||||||
cfg.DataDir = "" // unless explicitly requested, use memory databases
|
cfg.DataDir = "" // unless explicitly requested, use memory databases
|
||||||
case ctx.GlobalBool(TestnetFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
case ctx.GlobalBool(RopstenFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
||||||
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet")
|
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet")
|
||||||
case ctx.GlobalBool(RinkebyFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
case ctx.GlobalBool(RinkebyFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
||||||
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby")
|
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby")
|
||||||
case ctx.GlobalBool(GoerliFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
case (ctx.GlobalBool(TestnetFlag.Name) || ctx.GlobalBool(GoerliFlag.Name)) && cfg.DataDir == node.DefaultDataDir():
|
||||||
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "goerli")
|
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "goerli")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1441,7 +1445,7 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) {
|
||||||
// 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, TestnetFlag, RinkebyFlag, GoerliFlag)
|
CheckExclusive(ctx, DeveloperFlag, TestnetFlag, RopstenFlag, RinkebyFlag, GoerliFlag)
|
||||||
CheckExclusive(ctx, LightLegacyServFlag, LightServeFlag, SyncModeFlag, "light")
|
CheckExclusive(ctx, LightLegacyServFlag, 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
|
||||||
|
|
||||||
|
|
@ -1521,19 +1525,19 @@ 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(TestnetFlag.Name):
|
case ctx.GlobalBool(RopstenFlag.Name):
|
||||||
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
|
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
|
||||||
cfg.NetworkId = 3
|
cfg.NetworkId = 3
|
||||||
}
|
}
|
||||||
cfg.Genesis = core.DefaultTestnetGenesisBlock()
|
cfg.Genesis = core.DefaultRopstenGenesisBlock()
|
||||||
setDNSDiscoveryDefaults(cfg, params.KnownDNSNetworks[params.TestnetGenesisHash])
|
setDNSDiscoveryDefaults(cfg, params.KnownDNSNetworks[params.RopstenGenesisHash])
|
||||||
case ctx.GlobalBool(RinkebyFlag.Name):
|
case ctx.GlobalBool(RinkebyFlag.Name):
|
||||||
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
|
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
|
||||||
cfg.NetworkId = 4
|
cfg.NetworkId = 4
|
||||||
}
|
}
|
||||||
cfg.Genesis = core.DefaultRinkebyGenesisBlock()
|
cfg.Genesis = core.DefaultRinkebyGenesisBlock()
|
||||||
setDNSDiscoveryDefaults(cfg, params.KnownDNSNetworks[params.RinkebyGenesisHash])
|
setDNSDiscoveryDefaults(cfg, params.KnownDNSNetworks[params.RinkebyGenesisHash])
|
||||||
case ctx.GlobalBool(GoerliFlag.Name):
|
case ctx.GlobalBool(TestnetFlag.Name) || ctx.GlobalBool(GoerliFlag.Name):
|
||||||
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
|
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
|
||||||
cfg.NetworkId = 5
|
cfg.NetworkId = 5
|
||||||
}
|
}
|
||||||
|
|
@ -1708,11 +1712,11 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database {
|
||||||
func MakeGenesis(ctx *cli.Context) *core.Genesis {
|
func MakeGenesis(ctx *cli.Context) *core.Genesis {
|
||||||
var genesis *core.Genesis
|
var genesis *core.Genesis
|
||||||
switch {
|
switch {
|
||||||
case ctx.GlobalBool(TestnetFlag.Name):
|
case ctx.GlobalBool(RopstenFlag.Name):
|
||||||
genesis = core.DefaultTestnetGenesisBlock()
|
genesis = core.DefaultRopstenGenesisBlock()
|
||||||
case ctx.GlobalBool(RinkebyFlag.Name):
|
case ctx.GlobalBool(RinkebyFlag.Name):
|
||||||
genesis = core.DefaultRinkebyGenesisBlock()
|
genesis = core.DefaultRinkebyGenesisBlock()
|
||||||
case ctx.GlobalBool(GoerliFlag.Name):
|
case ctx.GlobalBool(TestnetFlag.Name) || ctx.GlobalBool(GoerliFlag.Name):
|
||||||
genesis = core.DefaultGoerliGenesisBlock()
|
genesis = core.DefaultGoerliGenesisBlock()
|
||||||
case ctx.GlobalBool(DeveloperFlag.Name):
|
case ctx.GlobalBool(DeveloperFlag.Name):
|
||||||
Fatalf("Developer chains are ephemeral")
|
Fatalf("Developer chains are ephemeral")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue