aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/gdex/misccmd.go
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-10-24 18:59:48 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:51 +0800
commit832edda709e2d6414e417e8e561b9cc83f8f09bb (patch)
treed797fb233f3fb6758b69d2550440cfad40765e5d /cmd/gdex/misccmd.go
parentd8b0b71610758cc7d218a012f27071937efff60e (diff)
downloadgo-tangerine-832edda709e2d6414e417e8e561b9cc83f8f09bb.tar
go-tangerine-832edda709e2d6414e417e8e561b9cc83f8f09bb.tar.gz
go-tangerine-832edda709e2d6414e417e8e561b9cc83f8f09bb.tar.bz2
go-tangerine-832edda709e2d6414e417e8e561b9cc83f8f09bb.tar.lz
go-tangerine-832edda709e2d6414e417e8e561b9cc83f8f09bb.tar.xz
go-tangerine-832edda709e2d6414e417e8e561b9cc83f8f09bb.tar.zst
go-tangerine-832edda709e2d6414e417e8e561b9cc83f8f09bb.zip
Rename geth -> gdex and fix Dockerfile
Diffstat (limited to 'cmd/gdex/misccmd.go')
-rw-r--r--cmd/gdex/misccmd.go139
1 files changed, 139 insertions, 0 deletions
diff --git a/cmd/gdex/misccmd.go b/cmd/gdex/misccmd.go
new file mode 100644
index 000000000..8800c7376
--- /dev/null
+++ b/cmd/gdex/misccmd.go
@@ -0,0 +1,139 @@
+// 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/dexon-foundation/dexon/cmd/utils"
+ "github.com/dexon-foundation/dexon/consensus/ethash"
+ "github.com/dexon-foundation/dexon/eth"
+ "github.com/dexon-foundation/dexon/params"
+ "gopkg.in/urfave/cli.v1"
+)
+
+var (
+ 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.
+`,
+ }
+ makedagCommand = cli.Command{
+ Action: utils.MigrateFlags(makedag),
+ Name: "makedag",
+ Usage: "Generate ethash mining DAG (for testing)",
+ ArgsUsage: "<blockNum> <outputDir>",
+ Category: "MISCELLANEOUS COMMANDS",
+ Description: `
+The makedag command generates an ethash DAG in <outputDir>.
+
+This command exists to support the system testing project.
+Regular users do not need to execute it.
+`,
+ }
+ versionCommand = cli.Command{
+ Action: utils.MigrateFlags(version),
+ 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{
+ Action: utils.MigrateFlags(license),
+ Name: "license",
+ Usage: "Display license information",
+ ArgsUsage: " ",
+ Category: "MISCELLANEOUS COMMANDS",
+ }
+)
+
+// 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: gdex 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.
+func makedag(ctx *cli.Context) error {
+ args := ctx.Args()
+ if len(args) != 2 {
+ utils.Fatalf(`Usage: gdex makedag <block number> <outputdir>`)
+ }
+ block, err := strconv.ParseUint(args[0], 0, 64)
+ if err != nil {
+ utils.Fatalf("Invalid block number: %v", err)
+ }
+ ethash.MakeDataset(block, args[1])
+
+ return nil
+}
+
+func version(ctx *cli.Context) error {
+ fmt.Println(strings.Title(clientIdentifier))
+ fmt.Println("Version:", params.VersionWithMeta)
+ if gitCommit != "" {
+ fmt.Println("Git Commit:", gitCommit)
+ }
+ fmt.Println("Architecture:", runtime.GOARCH)
+ fmt.Println("Protocol Versions:", eth.ProtocolVersions)
+ fmt.Println("Network Id:", eth.DefaultConfig.NetworkId)
+ fmt.Println("Go Version:", runtime.Version())
+ fmt.Println("Operating System:", runtime.GOOS)
+ 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
+along with gdex. If not, see <http://www.gnu.org/licenses/>.`)
+ return nil
+}