@@ -20,20 +20,15 @@ package main
2020import (
2121 "encoding/hex"
2222 "fmt"
23- "io/ioutil"
2423 "os"
25- "path/filepath"
2624 "runtime"
27- "strconv"
2825 "strings"
2926 "time"
3027
31- "github.com/ethereum/ethash"
3228 "github.com/ethereum/go-ethereum/cmd/utils"
3329 "github.com/ethereum/go-ethereum/common"
3430 "github.com/ethereum/go-ethereum/console"
3531 "github.com/ethereum/go-ethereum/contracts/release"
36- "github.com/ethereum/go-ethereum/core"
3732 "github.com/ethereum/go-ethereum/eth"
3833 "github.com/ethereum/go-ethereum/internal/debug"
3934 "github.com/ethereum/go-ethereum/logger"
@@ -64,59 +59,26 @@ func init() {
6459 app .HideVersion = true // we have a command to print the version
6560 app .Copyright = "Copyright 2013-2016 The go-ethereum Authors"
6661 app .Commands = []cli.Command {
62+ // See chaincmd.go:
63+ initCommand ,
6764 importCommand ,
6865 exportCommand ,
6966 upgradedbCommand ,
7067 removedbCommand ,
7168 dumpCommand ,
69+ // See monitorcmd.go:
7270 monitorCommand ,
71+ // See accountcmd.go:
7372 accountCommand ,
7473 walletCommand ,
74+ // See consolecmd.go:
7575 consoleCommand ,
7676 attachCommand ,
7777 javascriptCommand ,
78- {
79- Action : makedag ,
80- Name : "makedag" ,
81- Usage : "Generate ethash DAG (for testing)" ,
82- ArgsUsage : "<blockNum> <outputDir>" ,
83- Category : "MISCELLANEOUS COMMANDS" ,
84- Description : `
85- The makedag command generates an ethash DAG in /tmp/dag.
86-
87- This command exists to support the system testing project.
88- Regular users do not need to execute it.
89- ` ,
90- },
91- {
92- Action : version ,
93- Name : "version" ,
94- Usage : "Print version numbers" ,
95- ArgsUsage : " " ,
96- Category : "MISCELLANEOUS COMMANDS" ,
97- Description : `
98- The output of this command is supposed to be machine-readable.
99- ` ,
100- },
101- {
102- Action : initGenesis ,
103- Name : "init" ,
104- Usage : "Bootstrap and initialize a new genesis block" ,
105- ArgsUsage : "<genesisPath>" ,
106- Category : "BLOCKCHAIN COMMANDS" ,
107- Description : `
108- The init command initializes a new genesis block and definition for the network.
109- This is a destructive action and changes the network in which you will be
110- participating.
111- ` ,
112- },
113- {
114- Action : license ,
115- Name : "license" ,
116- Usage : "Display license information" ,
117- ArgsUsage : " " ,
118- Category : "MISCELLANEOUS COMMANDS" ,
119- },
78+ // See misccmd.go:
79+ makedagCommand ,
80+ versionCommand ,
81+ licenseCommand ,
12082 }
12183
12284 app .Flags = []cli.Flag {
@@ -230,30 +192,6 @@ func geth(ctx *cli.Context) error {
230192 return nil
231193}
232194
233- // initGenesis will initialise the given JSON format genesis file and writes it as
234- // the zero'd block (i.e. genesis) or will fail hard if it can't succeed.
235- func initGenesis (ctx * cli.Context ) error {
236- genesisPath := ctx .Args ().First ()
237- if len (genesisPath ) == 0 {
238- utils .Fatalf ("must supply path to genesis JSON file" )
239- }
240-
241- stack := makeFullNode (ctx )
242- chaindb := utils .MakeChainDatabase (ctx , stack )
243-
244- genesisFile , err := os .Open (genesisPath )
245- if err != nil {
246- utils .Fatalf ("failed to read genesis file: %v" , err )
247- }
248-
249- block , err := core .WriteGenesisBlock (chaindb , genesisFile )
250- if err != nil {
251- utils .Fatalf ("failed to write genesis block: %v" , err )
252- }
253- glog .V (logger .Info ).Infof ("successfully wrote genesis block and/or chain rule set: %x" , block .Hash ())
254- return nil
255- }
256-
257195func makeFullNode (ctx * cli.Context ) * node.Node {
258196 // Create the default extradata and construct the base node
259197 var clientInfo = struct {
@@ -328,65 +266,3 @@ func startNode(ctx *cli.Context, stack *node.Node) {
328266 }
329267 }
330268}
331-
332- func makedag (ctx * cli.Context ) error {
333- args := ctx .Args ()
334- wrongArgs := func () {
335- utils .Fatalf (`Usage: geth makedag <block number> <outputdir>` )
336- }
337- switch {
338- case len (args ) == 2 :
339- blockNum , err := strconv .ParseUint (args [0 ], 0 , 64 )
340- dir := args [1 ]
341- if err != nil {
342- wrongArgs ()
343- } else {
344- dir = filepath .Clean (dir )
345- // seems to require a trailing slash
346- if ! strings .HasSuffix (dir , "/" ) {
347- dir = dir + "/"
348- }
349- _ , err = ioutil .ReadDir (dir )
350- if err != nil {
351- utils .Fatalf ("Can't find dir" )
352- }
353- fmt .Println ("making DAG, this could take awhile..." )
354- ethash .MakeDAG (blockNum , dir )
355- }
356- default :
357- wrongArgs ()
358- }
359- return nil
360- }
361-
362- func version (ctx * cli.Context ) error {
363- fmt .Println (strings .Title (clientIdentifier ))
364- fmt .Println ("Version:" , params .Version )
365- if gitCommit != "" {
366- fmt .Println ("Git Commit:" , gitCommit )
367- }
368- fmt .Println ("Protocol Versions:" , eth .ProtocolVersions )
369- fmt .Println ("Network Id:" , ctx .GlobalInt (utils .NetworkIdFlag .Name ))
370- fmt .Println ("Go Version:" , runtime .Version ())
371- fmt .Println ("OS:" , runtime .GOOS )
372- fmt .Printf ("GOPATH=%s\n " , os .Getenv ("GOPATH" ))
373- fmt .Printf ("GOROOT=%s\n " , runtime .GOROOT ())
374- return nil
375- }
376-
377- func license (_ * cli.Context ) error {
378- fmt .Println (`Geth is free software: you can redistribute it and/or modify
379- it under the terms of the GNU General Public License as published by
380- the Free Software Foundation, either version 3 of the License, or
381- (at your option) any later version.
382-
383- Geth is distributed in the hope that it will be useful,
384- but WITHOUT ANY WARRANTY; without even the implied warranty of
385- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
386- GNU General Public License for more details.
387-
388- You should have received a copy of the GNU General Public License
389- along with geth. If not, see <http://www.gnu.org/licenses/>.
390- ` )
391- return nil
392- }
0 commit comments