clean up CLI options

This commit is contained in:
Tuna 2018-09-28 16:15:33 +07:00
parent 0db859674a
commit 1c1624b13e
9 changed files with 135 additions and 138 deletions

View file

@ -32,7 +32,7 @@ import (
var ( var (
walletCommand = cli.Command{ walletCommand = cli.Command{
Name: "wallet", Name: "wallet",
Usage: "Manage Ethereum presale wallets", Usage: "Manage Tomochain presale wallets",
ArgsUsage: "", ArgsUsage: "",
Category: "ACCOUNT COMMANDS", Category: "ACCOUNT COMMANDS",
Description: ` Description: `
@ -45,7 +45,7 @@ passwordfile as argument containing the wallet password in plaintext.`,
{ {
Name: "import", Name: "import",
Usage: "Import Ethereum presale wallet", Usage: "Import Tomochain presale wallet",
ArgsUsage: "<keyFile>", ArgsUsage: "<keyFile>",
Action: utils.MigrateFlags(importWallet), Action: utils.MigrateFlags(importWallet),
Category: "ACCOUNT COMMANDS", Category: "ACCOUNT COMMANDS",

View file

@ -31,7 +31,7 @@ import (
) )
const ( 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" ipcAPIs = "admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0"
httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0" httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0"
) )
@ -43,7 +43,7 @@ func TestConsoleWelcome(t *testing.T) {
// Start a tomo console, make sure it's cleaned up and terminate the console // Start a tomo console, make sure it's cleaned up and terminate the console
tomo := runTomo(t, tomo := runTomo(t,
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none", "--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
"--etherbase", coinbase, "--shh", "--etherbase", coinbase,
"console") "console")
// Gather all the infos the welcome message needs to contain // Gather all the infos the welcome message needs to contain
@ -81,11 +81,9 @@ func TestIPCAttachWelcome(t *testing.T) {
defer os.RemoveAll(ws) defer os.RemoveAll(ws)
ipc = filepath.Join(ws, "tomo.ipc") ipc = filepath.Join(ws, "tomo.ipc")
} }
// Note: we need --shh because testAttachWelcome checks for default
// list of ipc modules and shh is included there.
tomo := runTomo(t, tomo := runTomo(t,
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none", "--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
"--etherbase", coinbase, "--shh", "--ipcpath", ipc) "--etherbase", coinbase, "--ipcpath", ipc)
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
testAttachWelcome(t, tomo, "ipc:"+ipc, ipcAPIs) testAttachWelcome(t, tomo, "ipc:"+ipc, ipcAPIs)

View file

@ -58,38 +58,38 @@ var (
utils.BootnodesV5Flag, utils.BootnodesV5Flag,
utils.DataDirFlag, utils.DataDirFlag,
utils.KeyStoreDirFlag, utils.KeyStoreDirFlag,
utils.NoUSBFlag, //utils.NoUSBFlag,
utils.DashboardEnabledFlag, //utils.DashboardEnabledFlag,
utils.DashboardAddrFlag, //utils.DashboardAddrFlag,
utils.DashboardPortFlag, //utils.DashboardPortFlag,
utils.DashboardRefreshFlag, //utils.DashboardRefreshFlag,
utils.EthashCacheDirFlag, //utils.EthashCacheDirFlag,
utils.EthashCachesInMemoryFlag, //utils.EthashCachesInMemoryFlag,
utils.EthashCachesOnDiskFlag, //utils.EthashCachesOnDiskFlag,
utils.EthashDatasetDirFlag, //utils.EthashDatasetDirFlag,
utils.EthashDatasetsInMemoryFlag, //utils.EthashDatasetsInMemoryFlag,
utils.EthashDatasetsOnDiskFlag, //utils.EthashDatasetsOnDiskFlag,
utils.TxPoolNoLocalsFlag, //utils.TxPoolNoLocalsFlag,
utils.TxPoolJournalFlag, //utils.TxPoolJournalFlag,
utils.TxPoolRejournalFlag, //utils.TxPoolRejournalFlag,
utils.TxPoolPriceLimitFlag, //utils.TxPoolPriceLimitFlag,
utils.TxPoolPriceBumpFlag, //utils.TxPoolPriceBumpFlag,
utils.TxPoolAccountSlotsFlag, //utils.TxPoolAccountSlotsFlag,
utils.TxPoolGlobalSlotsFlag, //utils.TxPoolGlobalSlotsFlag,
utils.TxPoolAccountQueueFlag, //utils.TxPoolAccountQueueFlag,
utils.TxPoolGlobalQueueFlag, //utils.TxPoolGlobalQueueFlag,
utils.TxPoolLifetimeFlag, //utils.TxPoolLifetimeFlag,
utils.FastSyncFlag, utils.FastSyncFlag,
utils.LightModeFlag, utils.LightModeFlag,
utils.SyncModeFlag, utils.SyncModeFlag,
utils.GCModeFlag, utils.GCModeFlag,
utils.LightServFlag, //utils.LightServFlag,
utils.LightPeersFlag, //utils.LightPeersFlag,
utils.LightKDFFlag, //utils.LightKDFFlag,
utils.CacheFlag, //utils.CacheFlag,
utils.CacheDatabaseFlag, //utils.CacheDatabaseFlag,
utils.CacheGCFlag, //utils.CacheGCFlag,
utils.TrieCacheGenFlag, //utils.TrieCacheGenFlag,
utils.ListenPortFlag, utils.ListenPortFlag,
utils.MaxPeersFlag, utils.MaxPeersFlag,
utils.MaxPendingPeersFlag, utils.MaxPendingPeersFlag,
@ -100,25 +100,25 @@ var (
utils.TargetGasLimitFlag, utils.TargetGasLimitFlag,
utils.NATFlag, utils.NATFlag,
utils.NoDiscoverFlag, utils.NoDiscoverFlag,
utils.DiscoveryV5Flag, //utils.DiscoveryV5Flag,
utils.NetrestrictFlag, //utils.NetrestrictFlag,
utils.NodeKeyFileFlag, utils.NodeKeyFileFlag,
utils.NodeKeyHexFlag, utils.NodeKeyHexFlag,
utils.DeveloperFlag, //utils.DeveloperFlag,
utils.DeveloperPeriodFlag, //utils.DeveloperPeriodFlag,
utils.TestnetFlag, //utils.TestnetFlag,
utils.RinkebyFlag, //utils.RinkebyFlag,
utils.VMEnableDebugFlag, //utils.VMEnableDebugFlag,
utils.NetworkIdFlag, utils.NetworkIdFlag,
utils.RPCCORSDomainFlag, utils.RPCCORSDomainFlag,
utils.RPCVirtualHostsFlag, utils.RPCVirtualHostsFlag,
utils.EthStatsURLFlag, utils.EthStatsURLFlag,
utils.MetricsEnabledFlag, utils.MetricsEnabledFlag,
utils.FakePoWFlag, //utils.FakePoWFlag,
utils.NoCompactionFlag, //utils.NoCompactionFlag,
utils.GpoBlocksFlag, //utils.GpoBlocksFlag,
utils.GpoPercentileFlag, //utils.GpoPercentileFlag,
utils.ExtraDataFlag, //utils.ExtraDataFlag,
configFileFlag, configFileFlag,
} }
@ -153,13 +153,8 @@ func init() {
initCommand, initCommand,
importCommand, importCommand,
exportCommand, exportCommand,
importPreimagesCommand,
exportPreimagesCommand,
copydbCommand,
removedbCommand, removedbCommand,
dumpCommand, dumpCommand,
// See monitorcmd.go:
monitorCommand,
// See accountcmd.go: // See accountcmd.go:
accountCommand, accountCommand,
walletCommand, walletCommand,
@ -168,11 +163,7 @@ func init() {
attachCommand, attachCommand,
javascriptCommand, javascriptCommand,
// See misccmd.go: // See misccmd.go:
makecacheCommand,
makedagCommand,
versionCommand, versionCommand,
bugCommand,
licenseCommand,
// See config.go // See config.go
dumpConfigCommand, dumpConfigCommand,
} }
@ -182,7 +173,7 @@ func init() {
app.Flags = append(app.Flags, rpcFlags...) app.Flags = append(app.Flags, rpcFlags...)
app.Flags = append(app.Flags, consoleFlags...) app.Flags = append(app.Flags, consoleFlags...)
app.Flags = append(app.Flags, debug.Flags...) app.Flags = append(app.Flags, debug.Flags...)
app.Flags = append(app.Flags, whisperFlags...) //app.Flags = append(app.Flags, whisperFlags...)
app.Before = func(ctx *cli.Context) error { app.Before = func(ctx *cli.Context) error {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())

View file

@ -65,41 +65,41 @@ type flagGroup struct {
// AppHelpFlagGroups is the application flags, grouped by functionality. // AppHelpFlagGroups is the application flags, grouped by functionality.
var AppHelpFlagGroups = []flagGroup{ var AppHelpFlagGroups = []flagGroup{
{ {
Name: "ETHEREUM", Name: "TOMOCHAIN",
Flags: []cli.Flag{ Flags: []cli.Flag{
configFileFlag, configFileFlag,
utils.DataDirFlag, utils.DataDirFlag,
utils.KeyStoreDirFlag, utils.KeyStoreDirFlag,
utils.NoUSBFlag, //utils.NoUSBFlag,
utils.NetworkIdFlag, utils.NetworkIdFlag,
utils.TestnetFlag, //utils.TestnetFlag,
utils.RinkebyFlag, //utils.RinkebyFlag,
utils.SyncModeFlag, utils.SyncModeFlag,
utils.GCModeFlag, utils.GCModeFlag,
utils.EthStatsURLFlag, utils.EthStatsURLFlag,
utils.IdentityFlag, utils.IdentityFlag,
utils.LightServFlag, //utils.LightServFlag,
utils.LightPeersFlag, //utils.LightPeersFlag,
utils.LightKDFFlag, //utils.LightKDFFlag,
},
},
{Name: "DEVELOPER CHAIN",
Flags: []cli.Flag{
utils.DeveloperFlag,
utils.DeveloperPeriodFlag,
},
},
{
Name: "ETHASH",
Flags: []cli.Flag{
utils.EthashCacheDirFlag,
utils.EthashCachesInMemoryFlag,
utils.EthashCachesOnDiskFlag,
utils.EthashDatasetDirFlag,
utils.EthashDatasetsInMemoryFlag,
utils.EthashDatasetsOnDiskFlag,
}, },
}, },
//{Name: "DEVELOPER CHAIN",
// Flags: []cli.Flag{
// utils.DeveloperFlag,
// utils.DeveloperPeriodFlag,
// },
//},
//{
// Name: "ETHASH",
// Flags: []cli.Flag{
// utils.EthashCacheDirFlag,
// utils.EthashCachesInMemoryFlag,
// utils.EthashCachesOnDiskFlag,
// utils.EthashDatasetDirFlag,
// utils.EthashDatasetsInMemoryFlag,
// utils.EthashDatasetsOnDiskFlag,
// },
//},
//{ //{
// Name: "DASHBOARD", // Name: "DASHBOARD",
// Flags: []cli.Flag{ // Flags: []cli.Flag{
@ -110,30 +110,30 @@ var AppHelpFlagGroups = []flagGroup{
// utils.DashboardAssetsFlag, // utils.DashboardAssetsFlag,
// }, // },
//}, //},
{ //{
Name: "TRANSACTION POOL", // Name: "TRANSACTION POOL",
Flags: []cli.Flag{ // Flags: []cli.Flag{
utils.TxPoolNoLocalsFlag, // utils.TxPoolNoLocalsFlag,
utils.TxPoolJournalFlag, // utils.TxPoolJournalFlag,
utils.TxPoolRejournalFlag, // utils.TxPoolRejournalFlag,
utils.TxPoolPriceLimitFlag, // utils.TxPoolPriceLimitFlag,
utils.TxPoolPriceBumpFlag, // utils.TxPoolPriceBumpFlag,
utils.TxPoolAccountSlotsFlag, // utils.TxPoolAccountSlotsFlag,
utils.TxPoolGlobalSlotsFlag, // utils.TxPoolGlobalSlotsFlag,
utils.TxPoolAccountQueueFlag, // utils.TxPoolAccountQueueFlag,
utils.TxPoolGlobalQueueFlag, // utils.TxPoolGlobalQueueFlag,
utils.TxPoolLifetimeFlag, // utils.TxPoolLifetimeFlag,
}, // },
}, //},
{ //{
Name: "PERFORMANCE TUNING", // Name: "PERFORMANCE TUNING",
Flags: []cli.Flag{ // Flags: []cli.Flag{
utils.CacheFlag, // utils.CacheFlag,
utils.CacheDatabaseFlag, // utils.CacheDatabaseFlag,
utils.CacheGCFlag, // utils.CacheGCFlag,
utils.TrieCacheGenFlag, // utils.TrieCacheGenFlag,
}, // },
}, //},
{ {
Name: "ACCOUNT", Name: "ACCOUNT",
Flags: []cli.Flag{ Flags: []cli.Flag{
@ -173,14 +173,14 @@ var AppHelpFlagGroups = []flagGroup{
utils.MaxPendingPeersFlag, utils.MaxPendingPeersFlag,
utils.NATFlag, utils.NATFlag,
utils.NoDiscoverFlag, utils.NoDiscoverFlag,
utils.DiscoveryV5Flag, //utils.DiscoveryV5Flag,
utils.NetrestrictFlag, //utils.NetrestrictFlag,
utils.NodeKeyFileFlag, utils.NodeKeyFileFlag,
utils.NodeKeyHexFlag, utils.NodeKeyHexFlag,
}, },
}, },
{ {
Name: "MINER", Name: "STAKER",
Flags: []cli.Flag{ Flags: []cli.Flag{
utils.StakingEnabledFlag, utils.StakingEnabledFlag,
utils.StakerThreadsFlag, utils.StakerThreadsFlag,
@ -190,31 +190,31 @@ var AppHelpFlagGroups = []flagGroup{
utils.ExtraDataFlag, utils.ExtraDataFlag,
}, },
}, },
{ //{
Name: "GAS PRICE ORACLE", // Name: "GAS PRICE ORACLE",
Flags: []cli.Flag{ // Flags: []cli.Flag{
utils.GpoBlocksFlag, // utils.GpoBlocksFlag,
utils.GpoPercentileFlag, // utils.GpoPercentileFlag,
}, // },
}, //},
{ //{
Name: "VIRTUAL MACHINE", // Name: "VIRTUAL MACHINE",
Flags: []cli.Flag{ // Flags: []cli.Flag{
utils.VMEnableDebugFlag, // utils.VMEnableDebugFlag,
}, // },
}, //},
{ {
Name: "LOGGING AND DEBUGGING", Name: "LOGGING AND DEBUGGING",
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
utils.MetricsEnabledFlag, utils.MetricsEnabledFlag,
utils.FakePoWFlag, //utils.FakePoWFlag,
utils.NoCompactionFlag, //utils.NoCompactionFlag,
}, debug.Flags...), }, debug.Flags...),
}, },
{ //{
Name: "WHISPER (EXPERIMENTAL)", // Name: "WHISPER (EXPERIMENTAL)",
Flags: whisperFlags, // Flags: whisperFlags,
}, //},
{ {
Name: "DEPRECATED", Name: "DEPRECATED",
Flags: []cli.Flag{ Flags: []cli.Flag{

View file

@ -128,7 +128,7 @@ var (
} }
NetworkIdFlag = cli.Uint64Flag{ NetworkIdFlag = cli.Uint64Flag{
Name: "networkid", Name: "networkid",
Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby)", Usage: "Network identifier (integer, 89=Tomochain)",
Value: eth.DefaultConfig.NetworkId, Value: eth.DefaultConfig.NetworkId,
} }
TestnetFlag = cli.BoolFlag{ TestnetFlag = cli.BoolFlag{

View file

@ -43,7 +43,7 @@ var DefaultConfig = Config{
DatasetsInMem: 1, DatasetsInMem: 1,
DatasetsOnDisk: 2, DatasetsOnDisk: 2,
}, },
NetworkId: 1, NetworkId: 89,
LightPeers: 100, LightPeers: 100,
DatabaseCache: 768, DatabaseCache: 768,
TrieCache: 256, TrieCache: 256,

View file

@ -63,8 +63,8 @@ func testStatusMsgErrors(t *testing.T, protocol int) {
wantError: errResp(ErrProtocolVersionMismatch, "10 (!= %d)", protocol), wantError: errResp(ErrProtocolVersionMismatch, "10 (!= %d)", protocol),
}, },
{ {
code: StatusMsg, data: statusData{uint32(protocol), 999, td, head.Hash(), genesis.Hash()}, code: StatusMsg, data: statusData{uint32(protocol), 89, td, head.Hash(), genesis.Hash()},
wantError: errResp(ErrNetworkIdMismatch, "999 (!= 1)"), wantError: errResp(ErrNetworkIdMismatch, "89 (!= 1)"),
}, },
{ {
code: StatusMsg, data: statusData{uint32(protocol), DefaultConfig.NetworkId, td, head.Hash(), common.Hash{3}}, code: StatusMsg, data: statusData{uint32(protocol), DefaultConfig.NetworkId, td, head.Hash(), common.Hash{3}},
@ -85,7 +85,7 @@ func testStatusMsgErrors(t *testing.T, protocol int) {
} else if err.Error() != test.wantError.Error() { } else if err.Error() != test.wantError.Error() {
t.Errorf("test %d: wrong error: got %q, want %q", i, err, test.wantError) t.Errorf("test %d: wrong error: got %q, want %q", i, err, test.wantError)
} }
case <-time.After(2 * time.Second): case <-time.After(5 * time.Second):
t.Errorf("protocol did not shut down within 2 seconds") t.Errorf("protocol did not shut down within 2 seconds")
} }
p.close() p.close()

View file

@ -87,9 +87,17 @@ var (
// Flags holds all command-line flags required for debugging. // Flags holds all command-line flags required for debugging.
var Flags = []cli.Flag{ var Flags = []cli.Flag{
VerbosityFlag, vmoduleFlag, backtraceAtFlag, debugFlag, VerbosityFlag,
pprofFlag, pprofAddrFlag, pprofPortFlag, //vmoduleFlag,
memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag, //backtraceAtFlag,
//debugFlag,
//pprofFlag,
//pprofAddrFlag,
//pprofPortFlag,
//memprofilerateFlag,
//blockprofilerateFlag,
//cpuprofileFlag,
//traceFlag,
} }
var Glogger *log.GlogHandler var Glogger *log.GlogHandler

View file

@ -55,11 +55,11 @@ func DefaultDataDir() string {
home := homeDir() home := homeDir()
if home != "" { if home != "" {
if runtime.GOOS == "darwin" { if runtime.GOOS == "darwin" {
return filepath.Join(home, "Library", "Ethereum") return filepath.Join(home, "Library", "Tomochain")
} else if runtime.GOOS == "windows" { } else if runtime.GOOS == "windows" {
return filepath.Join(home, "AppData", "Roaming", "Ethereum") return filepath.Join(home, "AppData", "Roaming", "Tomochain")
} else { } else {
return filepath.Join(home, ".ethereum") return filepath.Join(home, ".tomo")
} }
} }
// As we cannot guess a stable location, return empty and handle later // As we cannot guess a stable location, return empty and handle later