2016-11-30 14:34:24 +03: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"
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"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 14:34:24 +03:00
|
|
|
"github.com/ethereum/go-ethereum/eth"
|
|
|
|
"github.com/ethereum/go-ethereum/params"
|
|
|
|
"gopkg.in/urfave/cli.v1"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
makedagCommand = cli.Command{
|
|
|
|
Action: makedag,
|
|
|
|
Name: "makedag",
|
|
|
|
Usage: "Generate ethash DAG (for testing)",
|
|
|
|
ArgsUsage: "<blockNum> <outputDir>",
|
|
|
|
Category: "MISCELLANEOUS COMMANDS",
|
|
|
|
Description: `
|
|
|
|
The makedag command generates an ethash DAG in /tmp/dag.
|
|
|
|
|
|
|
|
This command exists to support the system testing project.
|
|
|
|
Regular users do not need to execute it.
|
|
|
|
`,
|
|
|
|
}
|
|
|
|
versionCommand = cli.Command{
|
|
|
|
Action: 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: license,
|
|
|
|
Name: "license",
|
|
|
|
Usage: "Display license information",
|
|
|
|
ArgsUsage: " ",
|
|
|
|
Category: "MISCELLANEOUS COMMANDS",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func makedag(ctx *cli.Context) error {
|
|
|
|
args := ctx.Args()
|
|
|
|
wrongArgs := func() {
|
|
|
|
utils.Fatalf(`Usage: geth makedag <block number> <outputdir>`)
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case len(args) == 2:
|
|
|
|
blockNum, err := strconv.ParseUint(args[0], 0, 64)
|
|
|
|
dir := args[1]
|
|
|
|
if err != nil {
|
|
|
|
wrongArgs()
|
|
|
|
} else {
|
|
|
|
dir = filepath.Clean(dir)
|
|
|
|
// seems to require a trailing slash
|
|
|
|
if !strings.HasSuffix(dir, "/") {
|
|
|
|
dir = dir + "/"
|
|
|
|
}
|
|
|
|
_, err = ioutil.ReadDir(dir)
|
|
|
|
if err != nil {
|
|
|
|
utils.Fatalf("Can't find dir")
|
|
|
|
}
|
|
|
|
fmt.Println("making DAG, this could take awhile...")
|
2017-04-05 01:16:29 +03:00
|
|
|
ethash.MakeDataset(blockNum, dir)
|
2016-11-30 14:34:24 +03:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
wrongArgs()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func version(ctx *cli.Context) error {
|
|
|
|
fmt.Println(strings.Title(clientIdentifier))
|
|
|
|
fmt.Println("Version:", params.Version)
|
|
|
|
if gitCommit != "" {
|
|
|
|
fmt.Println("Git Commit:", gitCommit)
|
|
|
|
}
|
2017-04-05 22:51:01 +03:00
|
|
|
fmt.Println("Architecture:", runtime.GOARCH)
|
2016-11-30 14:34:24 +03:00
|
|
|
fmt.Println("Protocol Versions:", eth.ProtocolVersions)
|
|
|
|
fmt.Println("Network Id:", ctx.GlobalInt(utils.NetworkIdFlag.Name))
|
|
|
|
fmt.Println("Go Version:", runtime.Version())
|
2017-04-05 22:51:01 +03:00
|
|
|
fmt.Println("Operating System:", runtime.GOOS)
|
2016-11-30 14:34:24 +03: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
|
|
|
|
along with geth. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
`)
|
|
|
|
return nil
|
|
|
|
}
|