aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils/flags.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/utils/flags.go')
-rw-r--r--cmd/utils/flags.go47
1 files changed, 34 insertions, 13 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index c47301dfb..bb3c51fa1 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -150,13 +150,17 @@ var (
}
NetworkIdFlag = cli.Uint64Flag{
Name: "networkid",
- Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten)",
+ Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby)",
Value: eth.DefaultConfig.NetworkId,
}
- TestNetFlag = cli.BoolFlag{
+ TestnetFlag = cli.BoolFlag{
Name: "testnet",
Usage: "Ropsten network: pre-configured proof-of-work test network",
}
+ RinkebyFlag = cli.BoolFlag{
+ Name: "rinkeby",
+ Usage: "Rinkeby network: pre-configured proof-of-authority test network",
+ }
DevModeFlag = cli.BoolFlag{
Name: "dev",
Usage: "Developer mode: pre-configured private network with several debugging flags",
@@ -415,10 +419,12 @@ var (
// the a subdirectory of the specified datadir will be used.
func MakeDataDir(ctx *cli.Context) string {
if path := ctx.GlobalString(DataDirFlag.Name); path != "" {
- // TODO: choose a different location outside of the regular datadir.
- if ctx.GlobalBool(TestNetFlag.Name) {
+ if ctx.GlobalBool(TestnetFlag.Name) {
return filepath.Join(path, "testnet")
}
+ if ctx.GlobalBool(RinkebyFlag.Name) {
+ return filepath.Join(path, "rinkeby")
+ }
return path
}
Fatalf("Cannot determine default data directory, please set manually (--datadir)")
@@ -462,10 +468,13 @@ func setNodeUserIdent(ctx *cli.Context, cfg *node.Config) {
// flags, reverting to pre-configured ones if none have been specified.
func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls := params.MainnetBootnodes
- if ctx.GlobalIsSet(BootnodesFlag.Name) {
+ switch {
+ case ctx.GlobalIsSet(BootnodesFlag.Name):
urls = strings.Split(ctx.GlobalString(BootnodesFlag.Name), ",")
- } else if ctx.GlobalBool(TestNetFlag.Name) {
+ case ctx.GlobalBool(TestnetFlag.Name):
urls = params.TestnetBootnodes
+ case ctx.GlobalBool(RinkebyFlag.Name):
+ urls = params.RinkebyBootnodes
}
cfg.BootstrapNodes = make([]*discover.Node, 0, len(urls))
@@ -483,9 +492,12 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
// flags, reverting to pre-configured ones if none have been specified.
func setBootstrapNodesV5(ctx *cli.Context, cfg *p2p.Config) {
urls := params.DiscoveryV5Bootnodes
- if ctx.GlobalIsSet(BootnodesFlag.Name) {
+ switch {
+ case ctx.GlobalIsSet(BootnodesFlag.Name):
urls = strings.Split(ctx.GlobalString(BootnodesFlag.Name), ",")
- } else if cfg.BootstrapNodesV5 == nil {
+ case ctx.GlobalBool(RinkebyFlag.Name):
+ urls = params.RinkebyV5Bootnodes
+ case cfg.BootstrapNodesV5 != nil:
return // already set, don't apply defaults.
}
@@ -723,8 +735,10 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = ctx.GlobalString(DataDirFlag.Name)
case ctx.GlobalBool(DevModeFlag.Name):
cfg.DataDir = filepath.Join(os.TempDir(), "ethereum_dev_mode")
- case ctx.GlobalBool(TestNetFlag.Name):
+ case ctx.GlobalBool(TestnetFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet")
+ case ctx.GlobalBool(RinkebyFlag.Name):
+ cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby")
}
if ctx.GlobalIsSet(KeyStoreDirFlag.Name) {
@@ -783,7 +797,7 @@ func checkExclusive(ctx *cli.Context, flags ...cli.Flag) {
// SetEthConfig applies eth-related command line flags to the config.
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
// Avoid conflicting network flags
- checkExclusive(ctx, DevModeFlag, TestNetFlag)
+ checkExclusive(ctx, DevModeFlag, TestnetFlag, RinkebyFlag)
checkExclusive(ctx, FastSyncFlag, LightModeFlag, SyncModeFlag)
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
@@ -835,13 +849,18 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
cfg.EnablePreimageRecording = ctx.GlobalBool(VMEnableDebugFlag.Name)
}
- // Override any default configs for --dev and --testnet.
+ // Override any default configs for hard coded networks.
switch {
- case ctx.GlobalBool(TestNetFlag.Name):
+ case ctx.GlobalBool(TestnetFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 3
}
cfg.Genesis = core.DefaultTestnetGenesisBlock()
+ case ctx.GlobalBool(RinkebyFlag.Name):
+ if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
+ cfg.NetworkId = 4
+ }
+ cfg.Genesis = core.DefaultRinkebyGenesisBlock()
case ctx.GlobalBool(DevModeFlag.Name):
cfg.Genesis = core.DevGenesisBlock()
if !ctx.GlobalIsSet(GasPriceFlag.Name) {
@@ -928,8 +947,10 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database {
func MakeGenesis(ctx *cli.Context) *core.Genesis {
var genesis *core.Genesis
switch {
- case ctx.GlobalBool(TestNetFlag.Name):
+ case ctx.GlobalBool(TestnetFlag.Name):
genesis = core.DefaultTestnetGenesisBlock()
+ case ctx.GlobalBool(RinkebyFlag.Name):
+ genesis = core.DefaultRinkebyGenesisBlock()
case ctx.GlobalBool(DevModeFlag.Name):
genesis = core.DevGenesisBlock()
}