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