diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-05-04 18:54:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-04 18:54:02 +0800 |
commit | ff2c966e7f0550f4c0cb2b482d1af3064e6db0fe (patch) | |
tree | af4e387c4e9e2420e759078ebe4e1006dad28ea9 /cmd | |
parent | 14cc40a31a3f3aa229e6770911324daa2928ef57 (diff) | |
parent | d51a9fd6b7902e35990925c21bfeef427227c628 (diff) | |
download | go-tangerine-ff2c966e7f0550f4c0cb2b482d1af3064e6db0fe.tar go-tangerine-ff2c966e7f0550f4c0cb2b482d1af3064e6db0fe.tar.gz go-tangerine-ff2c966e7f0550f4c0cb2b482d1af3064e6db0fe.tar.bz2 go-tangerine-ff2c966e7f0550f4c0cb2b482d1af3064e6db0fe.tar.lz go-tangerine-ff2c966e7f0550f4c0cb2b482d1af3064e6db0fe.tar.xz go-tangerine-ff2c966e7f0550f4c0cb2b482d1af3064e6db0fe.tar.zst go-tangerine-ff2c966e7f0550f4c0cb2b482d1af3064e6db0fe.zip |
Merge pull request #14418 from karalabe/rinkeby-flag
cmd, core, params: add --rinkeby flag for fast connectivity
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/geth/main.go | 3 | ||||
-rw-r--r-- | cmd/geth/usage.go | 3 | ||||
-rw-r--r-- | cmd/utils/flags.go | 47 |
3 files changed, 38 insertions, 15 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 457a70bf9..7d9760cc9 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -88,7 +88,8 @@ var ( utils.NodeKeyHexFlag, utils.WhisperEnabledFlag, utils.DevModeFlag, - utils.TestNetFlag, + utils.TestnetFlag, + utils.RinkebyFlag, utils.VMEnableDebugFlag, utils.NetworkIdFlag, utils.RPCCORSDomainFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index 9f06a308b..5012a4b38 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -69,7 +69,8 @@ var AppHelpFlagGroups = []flagGroup{ utils.KeyStoreDirFlag, utils.NoUSBFlag, utils.NetworkIdFlag, - utils.TestNetFlag, + utils.TestnetFlag, + utils.RinkebyFlag, utils.DevModeFlag, utils.SyncModeFlag, utils.EthStatsURLFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 893fced8f..8ed294cae 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() } |