github.com/yinchengtsinghua/golang-Eos-dpos-Ethereum@v0.0.0-20190121132951-92cc4225ed8e/cmd/geth/misccmd.go (about) 1 2 //此源码被清华学神尹成大魔王专业翻译分析并修改 3 //尹成QQ77025077 4 //尹成微信18510341407 5 //尹成所在QQ群721929980 6 //尹成邮箱 yinc13@mails.tsinghua.edu.cn 7 //尹成毕业于清华大学,微软区块链领域全球最有价值专家 8 //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 9 //版权所有2016 Go Ethereum作者 10 //此文件是Go以太坊的一部分。 11 // 12 //Go以太坊是免费软件:您可以重新发布和/或修改它 13 //根据GNU通用公共许可证的条款 14 //自由软件基金会,或者许可证的第3版,或者 15 //(由您选择)任何更高版本。 16 // 17 //Go以太坊的分布希望它会有用, 18 //但没有任何保证;甚至没有 19 //适销性或特定用途的适用性。见 20 //GNU通用公共许可证了解更多详细信息。 21 // 22 //你应该已经收到一份GNU通用公共许可证的副本 23 //一起去以太坊吧。如果没有,请参见<http://www.gnu.org/licenses/>。 24 25 package main 26 27 import ( 28 "fmt" 29 "os" 30 "runtime" 31 "strconv" 32 "strings" 33 34 "github.com/ethereum/go-ethereum/cmd/utils" 35 "github.com/ethereum/go-ethereum/consensus/ethash" 36 "github.com/ethereum/go-ethereum/eth" 37 "github.com/ethereum/go-ethereum/params" 38 "gopkg.in/urfave/cli.v1" 39 ) 40 41 var ( 42 makecacheCommand = cli.Command{ 43 Action: utils.MigrateFlags(makecache), 44 Name: "makecache", 45 Usage: "Generate ethash verification cache (for testing)", 46 ArgsUsage: "<blockNum> <outputDir>", 47 Category: "MISCELLANEOUS COMMANDS", 48 Description: ` 49 The makecache command generates an ethash cache 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 makedagCommand = cli.Command{ 56 Action: utils.MigrateFlags(makedag), 57 Name: "makedag", 58 Usage: "Generate ethash mining DAG (for testing)", 59 ArgsUsage: "<blockNum> <outputDir>", 60 Category: "MISCELLANEOUS COMMANDS", 61 Description: ` 62 The makedag command generates an ethash DAG in <outputDir>. 63 64 This command exists to support the system testing project. 65 Regular users do not need to execute it. 66 `, 67 } 68 versionCommand = cli.Command{ 69 Action: utils.MigrateFlags(version), 70 Name: "version", 71 Usage: "Print version numbers", 72 ArgsUsage: " ", 73 Category: "MISCELLANEOUS COMMANDS", 74 Description: ` 75 The output of this command is supposed to be machine-readable. 76 `, 77 } 78 licenseCommand = cli.Command{ 79 Action: utils.MigrateFlags(license), 80 Name: "license", 81 Usage: "Display license information", 82 ArgsUsage: " ", 83 Category: "MISCELLANEOUS COMMANDS", 84 } 85 ) 86 87 // 88 func makecache(ctx *cli.Context) error { 89 args := ctx.Args() 90 if len(args) != 2 { 91 utils.Fatalf(`Usage: geth makecache <block number> <outputdir>`) 92 } 93 block, err := strconv.ParseUint(args[0], 0, 64) 94 if err != nil { 95 utils.Fatalf("Invalid block number: %v", err) 96 } 97 ethash.MakeCache(block, args[1]) 98 99 return nil 100 } 101 102 // 103 func makedag(ctx *cli.Context) error { 104 args := ctx.Args() 105 if len(args) != 2 { 106 utils.Fatalf(`Usage: geth makedag <block number> <outputdir>`) 107 } 108 block, err := strconv.ParseUint(args[0], 0, 64) 109 if err != nil { 110 utils.Fatalf("Invalid block number: %v", err) 111 } 112 ethash.MakeDataset(block, args[1]) 113 114 return nil 115 } 116 117 func version(ctx *cli.Context) error { 118 fmt.Println(strings.Title(clientIdentifier)) 119 fmt.Println("Version:", params.VersionWithMeta) 120 if gitCommit != "" { 121 fmt.Println("Git Commit:", gitCommit) 122 } 123 fmt.Println("Architecture:", runtime.GOARCH) 124 fmt.Println("Protocol Versions:", eth.ProtocolVersions) 125 fmt.Println("Network Id:", eth.DefaultConfig.NetworkId) 126 fmt.Println("Go Version:", runtime.Version()) 127 fmt.Println("Operating System:", runtime.GOOS) 128 fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH")) 129 fmt.Printf("GOROOT=%s\n", runtime.GOROOT()) 130 return nil 131 } 132 133 func license(_ *cli.Context) error { 134 fmt.Println(`Geth is free software: you can redistribute it and/or modify 135 it under the terms of the GNU General Public License as published by 136 the Free Software Foundation, either version 3 of the License, or 137 (at your option) any later version. 138 139 Geth is distributed in the hope that it will be useful, 140 but WITHOUT ANY WARRANTY; without even the implied warranty of 141 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 142 GNU General Public License for more details. 143 144 You should have received a copy of the GNU General Public License 145 along with geth. If not, see <http://www.gnu.org/licenses/>.`) 146 return nil 147 }