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