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