| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | // Copyright 2016 The go-ethereum Authors | 
					
						
							|  |  |  | // This file is part of go-ethereum. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // go-ethereum is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  | // it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  | // the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  | // (at your option) any later version. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // go-ethereum is distributed in the hope that it will be useful, | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
					
						
							|  |  |  | // GNU General Public License for more details. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  | // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package main | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"fmt" | 
					
						
							|  |  |  | 	"os" | 
					
						
							|  |  |  | 	"runtime" | 
					
						
							|  |  |  | 	"strconv" | 
					
						
							|  |  |  | 	"strings" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/ethereum/go-ethereum/cmd/utils" | 
					
						
							| 
									
										
										
										
											2017-04-05 01:16:29 +03:00
										 |  |  | 	"github.com/ethereum/go-ethereum/consensus/ethash" | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | 	"github.com/ethereum/go-ethereum/eth" | 
					
						
							|  |  |  | 	"github.com/ethereum/go-ethereum/params" | 
					
						
							|  |  |  | 	"gopkg.in/urfave/cli.v1" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var ( | 
					
						
							| 
									
										
										
										
											2017-08-03 06:32:47 +02:00
										 |  |  | 	makecacheCommand = cli.Command{ | 
					
						
							|  |  |  | 		Action:    utils.MigrateFlags(makecache), | 
					
						
							|  |  |  | 		Name:      "makecache", | 
					
						
							|  |  |  | 		Usage:     "Generate ethash verification cache (for testing)", | 
					
						
							|  |  |  | 		ArgsUsage: "<blockNum> <outputDir>", | 
					
						
							|  |  |  | 		Category:  "MISCELLANEOUS COMMANDS", | 
					
						
							|  |  |  | 		Description: ` | 
					
						
							|  |  |  | The makecache command generates an ethash cache in <outputDir>. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This command exists to support the system testing project. | 
					
						
							|  |  |  | Regular users do not need to execute it. | 
					
						
							|  |  |  | `, | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | 	makedagCommand = cli.Command{ | 
					
						
							| 
									
										
										
										
											2017-05-03 12:30:58 +02:00
										 |  |  | 		Action:    utils.MigrateFlags(makedag), | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | 		Name:      "makedag", | 
					
						
							| 
									
										
										
										
											2017-08-03 06:32:47 +02:00
										 |  |  | 		Usage:     "Generate ethash mining DAG (for testing)", | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | 		ArgsUsage: "<blockNum> <outputDir>", | 
					
						
							|  |  |  | 		Category:  "MISCELLANEOUS COMMANDS", | 
					
						
							|  |  |  | 		Description: ` | 
					
						
							| 
									
										
										
										
											2017-08-03 06:32:47 +02:00
										 |  |  | The makedag command generates an ethash DAG in <outputDir>. | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | This command exists to support the system testing project. | 
					
						
							|  |  |  | Regular users do not need to execute it. | 
					
						
							|  |  |  | `, | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	versionCommand = cli.Command{ | 
					
						
							| 
									
										
										
										
											2017-05-03 12:30:58 +02:00
										 |  |  | 		Action:    utils.MigrateFlags(version), | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | 		Name:      "version", | 
					
						
							|  |  |  | 		Usage:     "Print version numbers", | 
					
						
							|  |  |  | 		ArgsUsage: " ", | 
					
						
							|  |  |  | 		Category:  "MISCELLANEOUS COMMANDS", | 
					
						
							|  |  |  | 		Description: ` | 
					
						
							|  |  |  | The output of this command is supposed to be machine-readable. | 
					
						
							|  |  |  | `, | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	licenseCommand = cli.Command{ | 
					
						
							| 
									
										
										
										
											2017-05-03 12:30:58 +02:00
										 |  |  | 		Action:    utils.MigrateFlags(license), | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | 		Name:      "license", | 
					
						
							|  |  |  | 		Usage:     "Display license information", | 
					
						
							|  |  |  | 		ArgsUsage: " ", | 
					
						
							|  |  |  | 		Category:  "MISCELLANEOUS COMMANDS", | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-03 06:32:47 +02:00
										 |  |  | // makecache generates an ethash verification cache into the provided folder. | 
					
						
							|  |  |  | func makecache(ctx *cli.Context) error { | 
					
						
							|  |  |  | 	args := ctx.Args() | 
					
						
							|  |  |  | 	if len(args) != 2 { | 
					
						
							|  |  |  | 		utils.Fatalf(`Usage: geth makecache <block number> <outputdir>`) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	block, err := strconv.ParseUint(args[0], 0, 64) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		utils.Fatalf("Invalid block number: %v", err) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	ethash.MakeCache(block, args[1]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // makedag generates an ethash mining DAG into the provided folder. | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | func makedag(ctx *cli.Context) error { | 
					
						
							|  |  |  | 	args := ctx.Args() | 
					
						
							| 
									
										
										
										
											2017-08-03 06:32:47 +02:00
										 |  |  | 	if len(args) != 2 { | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | 		utils.Fatalf(`Usage: geth makedag <block number> <outputdir>`) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-08-03 06:32:47 +02:00
										 |  |  | 	block, err := strconv.ParseUint(args[0], 0, 64) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		utils.Fatalf("Invalid block number: %v", err) | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-08-03 06:32:47 +02:00
										 |  |  | 	ethash.MakeDataset(block, args[1]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func version(ctx *cli.Context) error { | 
					
						
							|  |  |  | 	fmt.Println(strings.Title(clientIdentifier)) | 
					
						
							| 
									
										
										
										
											2018-07-30 10:56:40 +02:00
										 |  |  | 	fmt.Println("Version:", params.VersionWithMeta) | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | 	if gitCommit != "" { | 
					
						
							|  |  |  | 		fmt.Println("Git Commit:", gitCommit) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-05-08 08:44:28 -05:00
										 |  |  | 	if gitDate != "" { | 
					
						
							|  |  |  | 		fmt.Println("Git Commit Date:", gitDate) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-04-05 22:51:01 +03:00
										 |  |  | 	fmt.Println("Architecture:", runtime.GOARCH) | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | 	fmt.Println("Protocol Versions:", eth.ProtocolVersions) | 
					
						
							|  |  |  | 	fmt.Println("Go Version:", runtime.Version()) | 
					
						
							| 
									
										
										
										
											2017-04-05 22:51:01 +03:00
										 |  |  | 	fmt.Println("Operating System:", runtime.GOOS) | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | 	fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH")) | 
					
						
							|  |  |  | 	fmt.Printf("GOROOT=%s\n", runtime.GOROOT()) | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func license(_ *cli.Context) error { | 
					
						
							|  |  |  | 	fmt.Println(`Geth is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  | it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  | the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  | (at your option) any later version. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Geth is distributed in the hope that it will be useful, | 
					
						
							|  |  |  | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
					
						
							|  |  |  | GNU General Public License for more details. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | You should have received a copy of the GNU General Public License | 
					
						
							| 
									
										
										
										
											2018-01-02 13:48:19 +02:00
										 |  |  | along with geth. If not, see <http://www.gnu.org/licenses/>.`) | 
					
						
							| 
									
										
										
										
											2016-11-30 13:34:24 +02:00
										 |  |  | 	return nil | 
					
						
							|  |  |  | } |