github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/cmd/geth/misccmd.go (about) 1 // This file is part of the go-sberex library. The go-sberex library is 2 // free software: you can redistribute it and/or modify it under the terms 3 // of the GNU Lesser General Public License as published by the Free 4 // Software Foundation, either version 3 of the License, or (at your option) 5 // any later version. 6 // 7 // The go-sberex library is distributed in the hope that it will be useful, 8 // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 // General Public License <http://www.gnu.org/licenses/> for more details. 11 12 package main 13 14 import ( 15 "fmt" 16 "os" 17 "runtime" 18 "strconv" 19 "strings" 20 21 "github.com/Sberex/go-sberex/cmd/utils" 22 "github.com/Sberex/go-sberex/consensus/ethash" 23 "github.com/Sberex/go-sberex/eth" 24 "github.com/Sberex/go-sberex/params" 25 "gopkg.in/urfave/cli.v1" 26 ) 27 28 var ( 29 makecacheCommand = cli.Command{ 30 Action: utils.MigrateFlags(makecache), 31 Name: "makecache", 32 Usage: "Generate ethash verification cache (for testing)", 33 ArgsUsage: "<blockNum> <outputDir>", 34 Category: "MISCELLANEOUS COMMANDS", 35 Description: ` 36 The makecache command generates an ethash cache in <outputDir>. 37 38 This command exists to support the system testing project. 39 Regular users do not need to execute it. 40 `, 41 } 42 makedagCommand = cli.Command{ 43 Action: utils.MigrateFlags(makedag), 44 Name: "makedag", 45 Usage: "Generate ethash mining DAG (for testing)", 46 ArgsUsage: "<blockNum> <outputDir>", 47 Category: "MISCELLANEOUS COMMANDS", 48 Description: ` 49 The makedag command generates an ethash DAG in <outputDir>. 50 51 This command exists to support the system testing project. 52 Regular users do not need to execute it. 53 `, 54 } 55 versionCommand = cli.Command{ 56 Action: utils.MigrateFlags(version), 57 Name: "version", 58 Usage: "Print version numbers", 59 ArgsUsage: " ", 60 Category: "MISCELLANEOUS COMMANDS", 61 Description: ` 62 The output of this command is supposed to be machine-readable. 63 `, 64 } 65 licenseCommand = cli.Command{ 66 Action: utils.MigrateFlags(license), 67 Name: "license", 68 Usage: "Display license information", 69 ArgsUsage: " ", 70 Category: "MISCELLANEOUS COMMANDS", 71 } 72 ) 73 74 // makecache generates an ethash verification cache into the provided folder. 75 func makecache(ctx *cli.Context) error { 76 args := ctx.Args() 77 if len(args) != 2 { 78 utils.Fatalf(`Usage: geth makecache <block number> <outputdir>`) 79 } 80 block, err := strconv.ParseUint(args[0], 0, 64) 81 if err != nil { 82 utils.Fatalf("Invalid block number: %v", err) 83 } 84 ethash.MakeCache(block, args[1]) 85 86 return nil 87 } 88 89 // makedag generates an ethash mining DAG into the provided folder. 90 func makedag(ctx *cli.Context) error { 91 args := ctx.Args() 92 if len(args) != 2 { 93 utils.Fatalf(`Usage: geth makedag <block number> <outputdir>`) 94 } 95 block, err := strconv.ParseUint(args[0], 0, 64) 96 if err != nil { 97 utils.Fatalf("Invalid block number: %v", err) 98 } 99 ethash.MakeDataset(block, args[1]) 100 101 return nil 102 } 103 104 func version(ctx *cli.Context) error { 105 fmt.Println(strings.Title(clientIdentifier)) 106 fmt.Println("Version:", params.Version) 107 if gitCommit != "" { 108 fmt.Println("Git Commit:", gitCommit) 109 } 110 fmt.Println("Architecture:", runtime.GOARCH) 111 fmt.Println("Protocol Versions:", eth.ProtocolVersions) 112 fmt.Println("Network Id:", eth.DefaultConfig.NetworkId) 113 fmt.Println("Go Version:", runtime.Version()) 114 fmt.Println("Operating System:", runtime.GOOS) 115 fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH")) 116 fmt.Printf("GOROOT=%s\n", runtime.GOROOT()) 117 return nil 118 } 119 120 func license(_ *cli.Context) error { 121 fmt.Println(`Geth is free software: you can redistribute it and/or modify 122 it under the terms of the GNU General Public License as published by 123 the Free Software Foundation, either version 3 of the License, or 124 (at your option) any later version. 125 126 Geth is distributed in the hope that it will be useful, 127 but WITHOUT ANY WARRANTY; without even the implied warranty of 128 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 129 GNU General Public License for more details. 130 131 You should have received a copy of the GNU General Public License 132 along with geth. If not, see <http://www.gnu.org/licenses/>.`) 133 return nil 134 }