diff options
Diffstat (limited to 'cmd/geth')
-rw-r--r-- | cmd/geth/accountcmd.go | 11 | ||||
-rw-r--r-- | cmd/geth/chaincmd.go | 16 | ||||
-rw-r--r-- | cmd/geth/config.go | 186 | ||||
-rw-r--r-- | cmd/geth/consolecmd_test.go | 42 | ||||
-rw-r--r-- | cmd/geth/dao_test.go | 24 | ||||
-rw-r--r-- | cmd/geth/main.go | 84 | ||||
-rw-r--r-- | cmd/geth/misccmd.go | 7 | ||||
-rw-r--r-- | cmd/geth/usage.go | 18 |
8 files changed, 246 insertions, 142 deletions
diff --git a/cmd/geth/accountcmd.go b/cmd/geth/accountcmd.go index f86be62ba..90f79a47e 100644 --- a/cmd/geth/accountcmd.go +++ b/cmd/geth/accountcmd.go @@ -179,8 +179,7 @@ nodes. ) func accountList(ctx *cli.Context) error { - stack := utils.MakeNode(ctx, clientIdentifier, gitCommit) - + stack, _ := makeConfigNode(ctx) var index int for _, wallet := range stack.AccountManager().Wallets() { for _, account := range wallet.Accounts() { @@ -278,7 +277,7 @@ func ambiguousAddrRecovery(ks *keystore.KeyStore, err *keystore.AmbiguousAddrErr // accountCreate creates a new account into the keystore defined by the CLI flags. func accountCreate(ctx *cli.Context) error { - stack := utils.MakeNode(ctx, clientIdentifier, gitCommit) + stack, _ := makeConfigNode(ctx) password := getPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0, utils.MakePasswordList(ctx)) ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) @@ -296,7 +295,7 @@ func accountUpdate(ctx *cli.Context) error { if len(ctx.Args()) == 0 { utils.Fatalf("No accounts specified to update") } - stack := utils.MakeNode(ctx, clientIdentifier, gitCommit) + stack, _ := makeConfigNode(ctx) ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) account, oldPassword := unlockAccount(ctx, ks, ctx.Args().First(), 0, nil) @@ -317,7 +316,7 @@ func importWallet(ctx *cli.Context) error { utils.Fatalf("Could not read wallet file: %v", err) } - stack := utils.MakeNode(ctx, clientIdentifier, gitCommit) + stack, _ := makeConfigNode(ctx) passphrase := getPassPhrase("", false, 0, utils.MakePasswordList(ctx)) ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) @@ -338,7 +337,7 @@ func accountImport(ctx *cli.Context) error { if err != nil { utils.Fatalf("Failed to load the private key: %v", err) } - stack := utils.MakeNode(ctx, clientIdentifier, gitCommit) + stack, _ := makeConfigNode(ctx) passphrase := getPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0, utils.MakePasswordList(ctx)) ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 6ea474a9c..66516b409 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -17,6 +17,7 @@ package main import ( + "encoding/json" "fmt" "os" "runtime" @@ -110,17 +111,22 @@ func initGenesis(ctx *cli.Context) error { stack := makeFullNode(ctx) chaindb := utils.MakeChainDatabase(ctx, stack) - genesisFile, err := os.Open(genesisPath) + file, err := os.Open(genesisPath) if err != nil { utils.Fatalf("failed to read genesis file: %v", err) } - defer genesisFile.Close() + defer file.Close() - block, err := core.WriteGenesisBlock(chaindb, genesisFile) + genesis := new(core.Genesis) + if err := json.NewDecoder(file).Decode(genesis); err != nil { + utils.Fatalf("invalid genesis file: %v", err) + } + + _, hash, err := core.SetupGenesisBlock(chaindb, genesis) if err != nil { utils.Fatalf("failed to write genesis block: %v", err) } - log.Info("Successfully wrote genesis state", "hash", block.Hash()) + log.Info("Successfully wrote genesis state", "hash", hash) return nil } @@ -238,7 +244,7 @@ func exportChain(ctx *cli.Context) error { } func removeDB(ctx *cli.Context) error { - stack := utils.MakeNode(ctx, clientIdentifier, gitCommit) + stack, _ := makeConfigNode(ctx) dbdir := stack.ResolvePath(utils.ChainDbName(ctx)) if !common.FileExist(dbdir) { fmt.Println(dbdir, "does not exist") diff --git a/cmd/geth/config.go b/cmd/geth/config.go new file mode 100644 index 000000000..86dd4bfdf --- /dev/null +++ b/cmd/geth/config.go @@ -0,0 +1,186 @@ +// Copyright 2015 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 ( + "bufio" + "encoding/hex" + "errors" + "fmt" + "io" + "os" + "reflect" + "unicode" + + cli "gopkg.in/urfave/cli.v1" + + "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/contracts/release" + "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/node" + "github.com/ethereum/go-ethereum/params" + "github.com/naoina/toml" +) + +var ( + dumpConfigCommand = cli.Command{ + Action: dumpConfig, + Name: "dumpconfig", + Usage: "Show configuration values", + ArgsUsage: "", + Category: "MISCELLANEOUS COMMANDS", + Description: `The dumpconfig command shows configuration values.`, + } + + configFileFlag = cli.StringFlag{ + Name: "config", + Usage: "TOML configuration file", + } +) + +// These settings ensure that TOML keys use the same names as Go struct fields. +var tomlSettings = toml.Config{ + NormFieldName: func(rt reflect.Type, key string) string { + return key + }, + FieldToKey: func(rt reflect.Type, field string) string { + return field + }, + MissingField: func(rt reflect.Type, field string) error { + link := "" + if unicode.IsUpper(rune(rt.Name()[0])) && rt.PkgPath() != "main" { + link = fmt.Sprintf(", see https://godoc.org/%s#%s for available fields", rt.PkgPath(), rt.Name()) + } + return fmt.Errorf("field '%s' is not defined in %s%s", field, rt.String(), link) + }, +} + +type ethstatsConfig struct { + URL string `toml:",omitempty"` +} + +type gethConfig struct { + Eth eth.Config + Node node.Config + Ethstats ethstatsConfig +} + +func loadConfig(file string, cfg *gethConfig) error { + f, err := os.Open(file) + if err != nil { + return err + } + defer f.Close() + + err = tomlSettings.NewDecoder(bufio.NewReader(f)).Decode(cfg) + // Add file name to errors that have a line number. + if _, ok := err.(*toml.LineError); ok { + err = errors.New(file + ", " + err.Error()) + } + return err +} + +func defaultNodeConfig() node.Config { + cfg := node.DefaultConfig + cfg.Name = clientIdentifier + cfg.Version = params.VersionWithCommit(gitCommit) + cfg.HTTPModules = append(cfg.HTTPModules, "eth") + cfg.WSModules = append(cfg.WSModules, "eth") + cfg.IPCPath = "geth.ipc" + return cfg +} + +func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) { + // Load defaults. + cfg := gethConfig{ + Eth: eth.DefaultConfig, + Node: defaultNodeConfig(), + } + + // Load config file. + if file := ctx.GlobalString(configFileFlag.Name); file != "" { + if err := loadConfig(file, &cfg); err != nil { + utils.Fatalf("%v", err) + } + } + + // Apply flags. + utils.SetNodeConfig(ctx, &cfg.Node) + stack, err := node.New(&cfg.Node) + if err != nil { + utils.Fatalf("Failed to create the protocol stack: %v", err) + } + utils.SetEthConfig(ctx, stack, &cfg.Eth) + if ctx.GlobalIsSet(utils.EthStatsURLFlag.Name) { + cfg.Ethstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name) + } + + return stack, cfg +} + +func makeFullNode(ctx *cli.Context) *node.Node { + stack, cfg := makeConfigNode(ctx) + + utils.RegisterEthService(stack, &cfg.Eth) + + // Whisper must be explicitly enabled, but is auto-enabled in --dev mode. + shhEnabled := ctx.GlobalBool(utils.WhisperEnabledFlag.Name) + shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DevModeFlag.Name) + if shhEnabled || shhAutoEnabled { + utils.RegisterShhService(stack) + } + + // Add the Ethereum Stats daemon if requested. + if cfg.Ethstats.URL != "" { + utils.RegisterEthStatsService(stack, cfg.Ethstats.URL) + } + + // Add the release oracle service so it boots along with node. + if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { + config := release.Config{ + Oracle: relOracle, + Major: uint32(params.VersionMajor), + Minor: uint32(params.VersionMinor), + Patch: uint32(params.VersionPatch), + } + commit, _ := hex.DecodeString(gitCommit) + copy(config.Commit[:], commit) + return release.NewReleaseService(ctx, config) + }); err != nil { + utils.Fatalf("Failed to register the Geth release oracle service: %v", err) + } + return stack +} + +// dumpConfig is the dumpconfig command. +func dumpConfig(ctx *cli.Context) error { + _, cfg := makeConfigNode(ctx) + comment := "" + + if cfg.Eth.Genesis != nil { + cfg.Eth.Genesis = nil + comment += "# Note: this config doesn't contain the genesis block.\n\n" + } + + out, err := tomlSettings.Marshal(&cfg) + if err != nil { + return err + } + io.WriteString(os.Stdout, comment) + os.Stdout.Write(out) + return nil +} diff --git a/cmd/geth/consolecmd_test.go b/cmd/geth/consolecmd_test.go index 820e9d082..e5472836c 100644 --- a/cmd/geth/consolecmd_test.go +++ b/cmd/geth/consolecmd_test.go @@ -22,14 +22,17 @@ import ( "os" "path/filepath" "runtime" - "sort" "strconv" "strings" "testing" "time" "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/rpc" +) + +const ( + ipcAPIs = "admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 shh:1.0 txpool:1.0 web3:1.0" + httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0" ) // Tests that a node embedded within a console can be started up properly and @@ -45,24 +48,21 @@ func TestConsoleWelcome(t *testing.T) { // Gather all the infos the welcome message needs to contain geth.setTemplateFunc("goos", func() string { return runtime.GOOS }) + geth.setTemplateFunc("goarch", func() string { return runtime.GOARCH }) geth.setTemplateFunc("gover", runtime.Version) geth.setTemplateFunc("gethver", func() string { return params.Version }) geth.setTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) }) - geth.setTemplateFunc("apis", func() []string { - apis := append(strings.Split(rpc.DefaultIPCApis, ","), rpc.MetadataApi) - sort.Strings(apis) - return apis - }) + geth.setTemplateFunc("apis", func() string { return ipcAPIs }) // Verify the actual welcome message to the required template geth.expect(` Welcome to the Geth JavaScript console! -instance: Geth/v{{gethver}}/{{goos}}/{{gover}} +instance: Geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}} coinbase: {{.Etherbase}} at block: 0 ({{niltime}}) datadir: {{.Datadir}} - modules:{{range apis}} {{.}}:1.0{{end}} + modules: {{apis}} > {{.InputLine "exit"}} `) @@ -88,7 +88,7 @@ func TestIPCAttachWelcome(t *testing.T) { "--etherbase", coinbase, "--shh", "--ipcpath", ipc) time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open - testAttachWelcome(t, geth, "ipc:"+ipc) + testAttachWelcome(t, geth, "ipc:"+ipc, ipcAPIs) geth.interrupt() geth.expectExit() @@ -102,7 +102,7 @@ func TestHTTPAttachWelcome(t *testing.T) { "--etherbase", coinbase, "--rpc", "--rpcport", port) time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open - testAttachWelcome(t, geth, "http://localhost:"+port) + testAttachWelcome(t, geth, "http://localhost:"+port, httpAPIs) geth.interrupt() geth.expectExit() @@ -117,13 +117,13 @@ func TestWSAttachWelcome(t *testing.T) { "--etherbase", coinbase, "--ws", "--wsport", port) time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open - testAttachWelcome(t, geth, "ws://localhost:"+port) + testAttachWelcome(t, geth, "ws://localhost:"+port, httpAPIs) geth.interrupt() geth.expectExit() } -func testAttachWelcome(t *testing.T, geth *testgeth, endpoint string) { +func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) { // Attach to a running geth note and terminate immediately attach := runGeth(t, "attach", endpoint) defer attach.expectExit() @@ -131,32 +131,24 @@ func testAttachWelcome(t *testing.T, geth *testgeth, endpoint string) { // Gather all the infos the welcome message needs to contain attach.setTemplateFunc("goos", func() string { return runtime.GOOS }) + attach.setTemplateFunc("goarch", func() string { return runtime.GOARCH }) attach.setTemplateFunc("gover", runtime.Version) attach.setTemplateFunc("gethver", func() string { return params.Version }) attach.setTemplateFunc("etherbase", func() string { return geth.Etherbase }) attach.setTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) }) attach.setTemplateFunc("ipc", func() bool { return strings.HasPrefix(endpoint, "ipc") }) attach.setTemplateFunc("datadir", func() string { return geth.Datadir }) - attach.setTemplateFunc("apis", func() []string { - var apis []string - if strings.HasPrefix(endpoint, "ipc") { - apis = append(strings.Split(rpc.DefaultIPCApis, ","), rpc.MetadataApi) - } else { - apis = append(strings.Split(rpc.DefaultHTTPApis, ","), rpc.MetadataApi) - } - sort.Strings(apis) - return apis - }) + attach.setTemplateFunc("apis", func() string { return apis }) // Verify the actual welcome message to the required template attach.expect(` Welcome to the Geth JavaScript console! -instance: Geth/v{{gethver}}/{{goos}}/{{gover}} +instance: Geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}} coinbase: {{etherbase}} at block: 0 ({{niltime}}){{if ipc}} datadir: {{datadir}}{{end}} - modules:{{range apis}} {{.}}:1.0{{end}} + modules: {{apis}} > {{.InputLine "exit" }} `) diff --git a/cmd/geth/dao_test.go b/cmd/geth/dao_test.go index f9ce80218..ec7802ada 100644 --- a/cmd/geth/dao_test.go +++ b/cmd/geth/dao_test.go @@ -84,27 +84,24 @@ var daoGenesisForkBlock = big.NewInt(314) // set in the database after various initialization procedures and invocations. func TestDAOForkBlockNewChain(t *testing.T) { for i, arg := range []struct { - testnet bool genesis string expectBlock *big.Int expectVote bool }{ // Test DAO Default Mainnet - {false, "", params.MainNetDAOForkBlock, true}, - // test DAO Default Testnet - {true, "", params.TestNetDAOForkBlock, true}, + {"", params.MainNetDAOForkBlock, true}, // test DAO Init Old Privnet - {false, daoOldGenesis, nil, false}, + {daoOldGenesis, nil, false}, // test DAO Default No Fork Privnet - {false, daoNoForkGenesis, daoGenesisForkBlock, false}, + {daoNoForkGenesis, daoGenesisForkBlock, false}, // test DAO Default Pro Fork Privnet - {false, daoProForkGenesis, daoGenesisForkBlock, true}, + {daoProForkGenesis, daoGenesisForkBlock, true}, } { - testDAOForkBlockNewChain(t, i, arg.testnet, arg.genesis, arg.expectBlock, arg.expectVote) + testDAOForkBlockNewChain(t, i, arg.genesis, arg.expectBlock, arg.expectVote) } } -func testDAOForkBlockNewChain(t *testing.T, test int, testnet bool, genesis string, expectBlock *big.Int, expectVote bool) { +func testDAOForkBlockNewChain(t *testing.T, test int, genesis string, expectBlock *big.Int, expectVote bool) { // Create a temporary data directory to use and inspect later datadir := tmpdir(t) defer os.RemoveAll(datadir) @@ -119,17 +116,11 @@ func testDAOForkBlockNewChain(t *testing.T, test int, testnet bool, genesis stri } else { // Force chain initialization args := []string{"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none", "--ipcdisable", "--datadir", datadir} - if testnet { - args = append(args, "--testnet") - } geth := runGeth(t, append(args, []string{"--exec", "2+2", "console"}...)...) geth.cmd.Wait() } // Retrieve the DAO config flag from the database path := filepath.Join(datadir, "geth", "chaindata") - if testnet && genesis == "" { - path = filepath.Join(datadir, "testnet", "geth", "chaindata") - } db, err := ethdb.NewLDBDatabase(path, 0, 0) if err != nil { t.Fatalf("test %d: failed to open test database: %v", test, err) @@ -137,9 +128,6 @@ func testDAOForkBlockNewChain(t *testing.T, test int, testnet bool, genesis stri defer db.Close() genesisHash := common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") - if testnet { - genesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") - } if genesis != "" { genesisHash = daoGenesisHash } diff --git a/cmd/geth/main.go b/cmd/geth/main.go index cc6d3ac6a..5fb50c4ad 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -18,7 +18,6 @@ package main import ( - "encoding/hex" "fmt" "os" "runtime" @@ -29,17 +28,13 @@ import ( "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/console" - "github.com/ethereum/go-ethereum/contracts/release" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/internal/debug" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/rlp" "gopkg.in/urfave/cli.v1" ) @@ -82,6 +77,8 @@ func init() { versionCommand, bugCommand, licenseCommand, + // See config.go + dumpConfigCommand, } app.Flags = []cli.Flag{ @@ -99,6 +96,7 @@ func init() { utils.EthashDatasetsOnDiskFlag, utils.FastSyncFlag, utils.LightModeFlag, + utils.SyncModeFlag, utils.LightServFlag, utils.LightPeersFlag, utils.LightKDFFlag, @@ -129,16 +127,12 @@ func init() { utils.WSApiFlag, utils.WSAllowedOriginsFlag, utils.IPCDisabledFlag, - utils.IPCApiFlag, utils.IPCPathFlag, utils.ExecFlag, utils.PreloadJSFlag, utils.WhisperEnabledFlag, utils.DevModeFlag, utils.TestNetFlag, - utils.VMForceJitFlag, - utils.VMJitCacheFlag, - utils.VMEnableJitFlag, utils.VMEnableDebugFlag, utils.NetworkIdFlag, utils.RPCCORSDomainFlag, @@ -146,14 +140,10 @@ func init() { utils.MetricsEnabledFlag, utils.FakePoWFlag, utils.NoCompactionFlag, - utils.SolcPathFlag, - utils.GpoMinGasPriceFlag, - utils.GpoMaxGasPriceFlag, - utils.GpoFullBlockRatioFlag, - utils.GpobaseStepDownFlag, - utils.GpobaseStepUpFlag, - utils.GpobaseCorrectionFactorFlag, + utils.GpoBlocksFlag, + utils.GpoPercentileFlag, utils.ExtraDataFlag, + configFileFlag, } app.Flags = append(app.Flags, debug.Flags...) @@ -165,12 +155,6 @@ func init() { // Start system runtime metrics collection go metrics.CollectProcessMetrics(3 * time.Second) - // This should be the only place where reporting is enabled - // because it is not intended to run while testing. - // In addition to this check, bad block reports are sent only - // for chains with the main network genesis block and network id 1. - eth.EnableBadBlockReporting = true - utils.SetupNetwork(ctx) return nil } @@ -199,52 +183,6 @@ func geth(ctx *cli.Context) error { return nil } -func makeFullNode(ctx *cli.Context) *node.Node { - // Create the default extradata and construct the base node - var clientInfo = struct { - Version uint - Name string - GoVersion string - Os string - }{uint(params.VersionMajor<<16 | params.VersionMinor<<8 | params.VersionPatch), clientIdentifier, runtime.Version(), runtime.GOOS} - extra, err := rlp.EncodeToBytes(clientInfo) - if err != nil { - log.Warn("Failed to set canonical miner information", "err", err) - } - if uint64(len(extra)) > params.MaximumExtraDataSize { - log.Warn("Miner extra data exceed limit", "extra", hexutil.Bytes(extra), "limit", params.MaximumExtraDataSize) - extra = nil - } - stack := utils.MakeNode(ctx, clientIdentifier, gitCommit) - utils.RegisterEthService(ctx, stack, extra) - - // Whisper must be explicitly enabled, but is auto-enabled in --dev mode. - shhEnabled := ctx.GlobalBool(utils.WhisperEnabledFlag.Name) - shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DevModeFlag.Name) - if shhEnabled || shhAutoEnabled { - utils.RegisterShhService(stack) - } - // Add the Ethereum Stats daemon if requested - if url := ctx.GlobalString(utils.EthStatsURLFlag.Name); url != "" { - utils.RegisterEthStatsService(stack, url) - } - // Add the release oracle service so it boots along with node. - if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { - config := release.Config{ - Oracle: relOracle, - Major: uint32(params.VersionMajor), - Minor: uint32(params.VersionMinor), - Patch: uint32(params.VersionPatch), - } - commit, _ := hex.DecodeString(gitCommit) - copy(config.Commit[:], commit) - return release.NewReleaseService(ctx, config) - }); err != nil { - utils.Fatalf("Failed to register the Geth release oracle service: %v", err) - } - return stack -} - // startNode boots up the system node and all registered protocols, after which // it unlocks any requested accounts, and starts the RPC/IPC interfaces and the // miner. @@ -303,7 +241,15 @@ func startNode(ctx *cli.Context, stack *node.Node) { if err := stack.Service(ðereum); err != nil { utils.Fatalf("ethereum service not running: %v", err) } - if err := ethereum.StartMining(ctx.GlobalInt(utils.MinerThreadsFlag.Name)); err != nil { + if threads := ctx.GlobalInt(utils.MinerThreadsFlag.Name); threads > 0 { + type threaded interface { + SetThreads(threads int) + } + if th, ok := ethereum.Engine().(threaded); ok { + th.SetThreads(threads) + } + } + if err := ethereum.StartMining(true); err != nil { utils.Fatalf("Failed to start mining: %v", err) } } diff --git a/cmd/geth/misccmd.go b/cmd/geth/misccmd.go index 073c36beb..cb7dc1673 100644 --- a/cmd/geth/misccmd.go +++ b/cmd/geth/misccmd.go @@ -26,9 +26,9 @@ import ( "strings" "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/pow" "gopkg.in/urfave/cli.v1" ) @@ -87,7 +87,7 @@ func makedag(ctx *cli.Context) error { utils.Fatalf("Can't find dir") } fmt.Println("making DAG, this could take awhile...") - pow.MakeDataset(blockNum, dir) + ethash.MakeDataset(blockNum, dir) } default: wrongArgs() @@ -101,10 +101,11 @@ func version(ctx *cli.Context) error { if gitCommit != "" { fmt.Println("Git Commit:", gitCommit) } + fmt.Println("Architecture:", runtime.GOARCH) fmt.Println("Protocol Versions:", eth.ProtocolVersions) fmt.Println("Network Id:", ctx.GlobalInt(utils.NetworkIdFlag.Name)) fmt.Println("Go Version:", runtime.Version()) - fmt.Println("OS:", runtime.GOOS) + fmt.Println("Operating System:", runtime.GOOS) fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH")) fmt.Printf("GOROOT=%s\n", runtime.GOROOT()) return nil diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index 74768f507..a172b4775 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -115,7 +115,6 @@ var AppHelpFlagGroups = []flagGroup{ utils.WSApiFlag, utils.WSAllowedOriginsFlag, utils.IPCDisabledFlag, - utils.IPCApiFlag, utils.IPCPathFlag, utils.RPCCORSDomainFlag, utils.JSpathFlag, @@ -151,20 +150,13 @@ var AppHelpFlagGroups = []flagGroup{ { Name: "GAS PRICE ORACLE", Flags: []cli.Flag{ - utils.GpoMinGasPriceFlag, - utils.GpoMaxGasPriceFlag, - utils.GpoFullBlockRatioFlag, - utils.GpobaseStepDownFlag, - utils.GpobaseStepUpFlag, - utils.GpobaseCorrectionFactorFlag, + utils.GpoBlocksFlag, + utils.GpoPercentileFlag, }, }, { Name: "VIRTUAL MACHINE", Flags: []cli.Flag{ - utils.VMEnableJitFlag, - utils.VMForceJitFlag, - utils.VMJitCacheFlag, utils.VMEnableDebugFlag, }, }, @@ -182,12 +174,6 @@ var AppHelpFlagGroups = []flagGroup{ utils.WhisperEnabledFlag, }, }, - { - Name: "MISCELLANEOUS", - Flags: []cli.Flag{ - utils.SolcPathFlag, - }, - }, } func init() { |