@@ -150,13 +150,17 @@ var (
150150 }
151151 NetworkIdFlag = cli.Uint64Flag {
152152 Name : "networkid" ,
153- Usage : "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten)" ,
153+ Usage : "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby )" ,
154154 Value : eth .DefaultConfig .NetworkId ,
155155 }
156- TestNetFlag = cli.BoolFlag {
156+ TestnetFlag = cli.BoolFlag {
157157 Name : "testnet" ,
158158 Usage : "Ropsten network: pre-configured proof-of-work test network" ,
159159 }
160+ RinkebyFlag = cli.BoolFlag {
161+ Name : "rinkeby" ,
162+ Usage : "Rinkeby network: pre-configured proof-of-authority test network" ,
163+ }
160164 DevModeFlag = cli.BoolFlag {
161165 Name : "dev" ,
162166 Usage : "Developer mode: pre-configured private network with several debugging flags" ,
@@ -415,10 +419,12 @@ var (
415419// the a subdirectory of the specified datadir will be used.
416420func MakeDataDir (ctx * cli.Context ) string {
417421 if path := ctx .GlobalString (DataDirFlag .Name ); path != "" {
418- // TODO: choose a different location outside of the regular datadir.
419- if ctx .GlobalBool (TestNetFlag .Name ) {
422+ if ctx .GlobalBool (TestnetFlag .Name ) {
420423 return filepath .Join (path , "testnet" )
421424 }
425+ if ctx .GlobalBool (RinkebyFlag .Name ) {
426+ return filepath .Join (path , "rinkeby" )
427+ }
422428 return path
423429 }
424430 Fatalf ("Cannot determine default data directory, please set manually (--datadir)" )
@@ -462,10 +468,13 @@ func setNodeUserIdent(ctx *cli.Context, cfg *node.Config) {
462468// flags, reverting to pre-configured ones if none have been specified.
463469func setBootstrapNodes (ctx * cli.Context , cfg * p2p.Config ) {
464470 urls := params .MainnetBootnodes
465- if ctx .GlobalIsSet (BootnodesFlag .Name ) {
471+ switch {
472+ case ctx .GlobalIsSet (BootnodesFlag .Name ):
466473 urls = strings .Split (ctx .GlobalString (BootnodesFlag .Name ), "," )
467- } else if ctx .GlobalBool (TestNetFlag .Name ) {
474+ case ctx .GlobalBool (TestnetFlag .Name ):
468475 urls = params .TestnetBootnodes
476+ case ctx .GlobalBool (RinkebyFlag .Name ):
477+ urls = params .RinkebyBootnodes
469478 }
470479
471480 cfg .BootstrapNodes = make ([]* discover.Node , 0 , len (urls ))
@@ -483,9 +492,12 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
483492// flags, reverting to pre-configured ones if none have been specified.
484493func setBootstrapNodesV5 (ctx * cli.Context , cfg * p2p.Config ) {
485494 urls := params .DiscoveryV5Bootnodes
486- if ctx .GlobalIsSet (BootnodesFlag .Name ) {
495+ switch {
496+ case ctx .GlobalIsSet (BootnodesFlag .Name ):
487497 urls = strings .Split (ctx .GlobalString (BootnodesFlag .Name ), "," )
488- } else if cfg .BootstrapNodesV5 == nil {
498+ case ctx .GlobalBool (RinkebyFlag .Name ):
499+ urls = params .RinkebyV5Bootnodes
500+ case cfg .BootstrapNodesV5 != nil :
489501 return // already set, don't apply defaults.
490502 }
491503
@@ -723,8 +735,10 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
723735 cfg .DataDir = ctx .GlobalString (DataDirFlag .Name )
724736 case ctx .GlobalBool (DevModeFlag .Name ):
725737 cfg .DataDir = filepath .Join (os .TempDir (), "ethereum_dev_mode" )
726- case ctx .GlobalBool (TestNetFlag .Name ):
738+ case ctx .GlobalBool (TestnetFlag .Name ):
727739 cfg .DataDir = filepath .Join (node .DefaultDataDir (), "testnet" )
740+ case ctx .GlobalBool (RinkebyFlag .Name ):
741+ cfg .DataDir = filepath .Join (node .DefaultDataDir (), "rinkeby" )
728742 }
729743
730744 if ctx .GlobalIsSet (KeyStoreDirFlag .Name ) {
@@ -783,7 +797,7 @@ func checkExclusive(ctx *cli.Context, flags ...cli.Flag) {
783797// SetEthConfig applies eth-related command line flags to the config.
784798func SetEthConfig (ctx * cli.Context , stack * node.Node , cfg * eth.Config ) {
785799 // Avoid conflicting network flags
786- checkExclusive (ctx , DevModeFlag , TestNetFlag )
800+ checkExclusive (ctx , DevModeFlag , TestnetFlag , RinkebyFlag )
787801 checkExclusive (ctx , FastSyncFlag , LightModeFlag , SyncModeFlag )
788802
789803 ks := stack .AccountManager ().Backends (keystore .KeyStoreType )[0 ].(* keystore.KeyStore )
@@ -835,13 +849,18 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
835849 cfg .EnablePreimageRecording = ctx .GlobalBool (VMEnableDebugFlag .Name )
836850 }
837851
838- // Override any default configs for --dev and --testnet .
852+ // Override any default configs for hard coded networks .
839853 switch {
840- case ctx .GlobalBool (TestNetFlag .Name ):
854+ case ctx .GlobalBool (TestnetFlag .Name ):
841855 if ! ctx .GlobalIsSet (NetworkIdFlag .Name ) {
842856 cfg .NetworkId = 3
843857 }
844858 cfg .Genesis = core .DefaultTestnetGenesisBlock ()
859+ case ctx .GlobalBool (RinkebyFlag .Name ):
860+ if ! ctx .GlobalIsSet (NetworkIdFlag .Name ) {
861+ cfg .NetworkId = 4
862+ }
863+ cfg .Genesis = core .DefaultRinkebyGenesisBlock ()
845864 case ctx .GlobalBool (DevModeFlag .Name ):
846865 cfg .Genesis = core .DevGenesisBlock ()
847866 if ! ctx .GlobalIsSet (GasPriceFlag .Name ) {
@@ -928,8 +947,10 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database {
928947func MakeGenesis (ctx * cli.Context ) * core.Genesis {
929948 var genesis * core.Genesis
930949 switch {
931- case ctx .GlobalBool (TestNetFlag .Name ):
950+ case ctx .GlobalBool (TestnetFlag .Name ):
932951 genesis = core .DefaultTestnetGenesisBlock ()
952+ case ctx .GlobalBool (RinkebyFlag .Name ):
953+ genesis = core .DefaultRinkebyGenesisBlock ()
933954 case ctx .GlobalBool (DevModeFlag .Name ):
934955 genesis = core .DevGenesisBlock ()
935956 }
0 commit comments