diff options
Diffstat (limited to 'cmd/geth')
-rw-r--r-- | cmd/geth/accountcmd_test.go | 12 | ||||
-rw-r--r-- | cmd/geth/main.go | 23 | ||||
-rw-r--r-- | cmd/geth/misccmd.go | 63 | ||||
-rw-r--r-- | cmd/geth/usage.go | 2 |
4 files changed, 62 insertions, 38 deletions
diff --git a/cmd/geth/accountcmd_test.go b/cmd/geth/accountcmd_test.go index e146323ee..66e3e02a4 100644 --- a/cmd/geth/accountcmd_test.go +++ b/cmd/geth/accountcmd_test.go @@ -146,7 +146,7 @@ Passphrase: {{.InputLine "foobar"}} wantMessages := []string{ "Unlocked account", - "=0xf466859ead1932d743d622cb74fc058882e8648a", + "=0xf466859eAD1932D743d622CB74FC058882E8648A", } for _, m := range wantMessages { if !strings.Contains(geth.StderrText(), m) { @@ -191,8 +191,8 @@ Passphrase: {{.InputLine "foobar"}} wantMessages := []string{ "Unlocked account", - "=0x7ef5a6135f1fd6a02593eedc869c6d41d934aef8", - "=0x289d485d9771714cce91d3393d764e1311907acc", + "=0x7EF5A6135f1FD6a02593eEdC869c6D41D934aef8", + "=0x289d485D9771714CCe91D3393D764E1311907ACc", } for _, m := range wantMessages { if !strings.Contains(geth.StderrText(), m) { @@ -211,8 +211,8 @@ func TestUnlockFlagPasswordFile(t *testing.T) { wantMessages := []string{ "Unlocked account", - "=0x7ef5a6135f1fd6a02593eedc869c6d41d934aef8", - "=0x289d485d9771714cce91d3393d764e1311907acc", + "=0x7EF5A6135f1FD6a02593eEdC869c6D41D934aef8", + "=0x289d485D9771714CCe91D3393D764E1311907ACc", } for _, m := range wantMessages { if !strings.Contains(geth.StderrText(), m) { @@ -261,7 +261,7 @@ In order to avoid this warning, you need to remove the following duplicate key f wantMessages := []string{ "Unlocked account", - "=0xf466859ead1932d743d622cb74fc058882e8648a", + "=0xf466859eAD1932D743d622CB74FC058882E8648A", } for _, m := range wantMessages { if !strings.Contains(geth.StderrText(), m) { diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 607414bbb..8166c9ce8 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -21,6 +21,7 @@ import ( "fmt" "os" "runtime" + "sort" "strings" "time" @@ -67,6 +68,8 @@ var ( utils.EthashDatasetsInMemoryFlag, utils.EthashDatasetsOnDiskFlag, utils.TxPoolNoLocalsFlag, + utils.TxPoolJournalFlag, + utils.TxPoolRejournalFlag, utils.TxPoolPriceLimitFlag, utils.TxPoolPriceBumpFlag, utils.TxPoolAccountSlotsFlag, @@ -155,6 +158,7 @@ func init() { attachCommand, javascriptCommand, // See misccmd.go: + makecacheCommand, makedagCommand, versionCommand, bugCommand, @@ -162,6 +166,7 @@ func init() { // See config.go dumpConfigCommand, } + sort.Sort(cli.CommandsByName(app.Commands)) app.Flags = append(app.Flags, nodeFlags...) app.Flags = append(app.Flags, rpcFlags...) @@ -234,24 +239,30 @@ func startNode(ctx *cli.Context, stack *node.Node) { } stateReader := ethclient.NewClient(rpcClient) - // Open and self derive any wallets already attached + // Open any wallets already attached for _, wallet := range stack.AccountManager().Wallets() { if err := wallet.Open(""); err != nil { log.Warn("Failed to open wallet", "url", wallet.URL(), "err", err) - } else { - wallet.SelfDerive(accounts.DefaultBaseDerivationPath, stateReader) } } // Listen for wallet event till termination for event := range events { - if event.Arrive { + switch event.Kind { + case accounts.WalletArrived: if err := event.Wallet.Open(""); err != nil { log.Warn("New wallet appeared, failed to open", "url", event.Wallet.URL(), "err", err) + } + case accounts.WalletOpened: + status, _ := event.Wallet.Status() + log.Info("New wallet appeared", "url", event.Wallet.URL(), "status", status) + + if event.Wallet.URL().Scheme == "ledger" { + event.Wallet.SelfDerive(accounts.DefaultLedgerBaseDerivationPath, stateReader) } else { - log.Info("New wallet appeared", "url", event.Wallet.URL(), "status", event.Wallet.Status()) event.Wallet.SelfDerive(accounts.DefaultBaseDerivationPath, stateReader) } - } else { + + case accounts.WalletDropped: log.Info("Old wallet dropped", "url", event.Wallet.URL()) event.Wallet.Close() } diff --git a/cmd/geth/misccmd.go b/cmd/geth/misccmd.go index 62b93d65a..2e68dcda3 100644 --- a/cmd/geth/misccmd.go +++ b/cmd/geth/misccmd.go @@ -18,9 +18,7 @@ package main import ( "fmt" - "io/ioutil" "os" - "path/filepath" "runtime" "strconv" "strings" @@ -33,14 +31,27 @@ import ( ) 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 DAG (for testing)", + Usage: "Generate ethash mining DAG (for testing)", ArgsUsage: "<blockNum> <outputDir>", Category: "MISCELLANEOUS COMMANDS", Description: ` -The makedag command generates an ethash DAG in /tmp/dag. +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. @@ -65,33 +76,33 @@ The output of this command is supposed to be machine-readable. } ) +// 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. func makedag(ctx *cli.Context) error { args := ctx.Args() - wrongArgs := func() { + if len(args) != 2 { 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...") - ethash.MakeDataset(blockNum, dir) - } - default: - wrongArgs() + 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 } diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index 275aad674..80861d852 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -96,6 +96,8 @@ var AppHelpFlagGroups = []flagGroup{ Name: "TRANSACTION POOL", Flags: []cli.Flag{ utils.TxPoolNoLocalsFlag, + utils.TxPoolJournalFlag, + utils.TxPoolRejournalFlag, utils.TxPoolPriceLimitFlag, utils.TxPoolPriceBumpFlag, utils.TxPoolAccountSlotsFlag, |