github.com/aquanetwork/aquachain@v1.7.8/cmd/aquachain/misccmd.go (about) 1 // Copyright 2016 The aquachain Authors 2 // This file is part of aquachain. 3 // 4 // aquachain 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 // aquachain 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 aquachain. 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 "gitlab.com/aquachain/aquachain/aqua" 27 "gitlab.com/aquachain/aquachain/cmd/utils" 28 "gitlab.com/aquachain/aquachain/consensus/aquahash" 29 "gitlab.com/aquachain/aquachain/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 aquahash verification cache (for testing)", 38 ArgsUsage: "<blockNum> <outputDir>", 39 Category: "MISCELLANEOUS COMMANDS", 40 Description: ` 41 The makecache command generates an aquahash 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 aquahash mining DAG (for testing)", 51 ArgsUsage: "<blockNum> <outputDir>", 52 Category: "MISCELLANEOUS COMMANDS", 53 Description: ` 54 The makedag command generates an aquahash 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 aquahash 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: aquachain 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 aquahash.MakeCache(block, args[1]) 90 91 return nil 92 } 93 94 // makedag generates an aquahash 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: aquachain 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 aquahash.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.Version) 112 if gitCommit != "" { 113 fmt.Println("Git Commit:", gitCommit) 114 } 115 fmt.Println("Architecture:", runtime.GOARCH) 116 fmt.Println("Protocol Versions:", aqua.ProtocolVersions) 117 fmt.Println("Network Id:", aqua.DefaultConfig.NetworkId) 118 fmt.Println("Go Version:", runtime.Version()) 119 fmt.Println("Operating System:", runtime.GOOS) 120 fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH")) 121 fmt.Printf("GOROOT=%s\n", runtime.GOROOT()) 122 return nil 123 } 124 125 func license(_ *cli.Context) error { 126 fmt.Println(`AquaChain is free software: you can redistribute it and/or modify 127 it under the terms of the GNU General Public License as published by 128 the Free Software Foundation, either version 3 of the License, or 129 (at your option) any later version. 130 131 AquaChain is distributed in the hope that it will be useful, 132 but WITHOUT ANY WARRANTY; without even the implied warranty of 133 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 134 GNU General Public License for more details. 135 136 You should have received a copy of the GNU General Public License 137 along with aquachain. If not, see <http://www.gnu.org/licenses/>.`) 138 return nil 139 }