github.com/ethereumproject/go-ethereum@v5.5.2+incompatible/cmd/geth/flags.go (about)

     1  package main
     2  
     3  import (
     4  	"math/big"
     5  	"runtime"
     6  
     7  	"strings"
     8  
     9  	"path/filepath"
    10  
    11  	"github.com/ethereumproject/go-ethereum/common"
    12  	"github.com/ethereumproject/go-ethereum/core"
    13  	"github.com/ethereumproject/go-ethereum/eth"
    14  	"github.com/ethereumproject/go-ethereum/logger/glog"
    15  	"github.com/ethereumproject/go-ethereum/rpc"
    16  	"gopkg.in/urfave/cli.v1"
    17  )
    18  
    19  // These are all the command line flags we support.
    20  // If you add to this list, please remember to include the
    21  // flag in the appropriate command definition.
    22  //
    23  // The flags are defined here so their names and help texts
    24  // are the same for all commands.
    25  
    26  var (
    27  	// General settings
    28  	PprofFlag = cli.IntFlag{
    29  		Name:  "pprof",
    30  		Usage: "Enable runtime profiling with web interface",
    31  		Value: 0,
    32  	}
    33  	PprofIntervalFlag = cli.IntFlag{
    34  		Name:  "pprof-interval",
    35  		Usage: "Set interval in seconds for runtime profiling",
    36  		Value: 5,
    37  	}
    38  	SputnikVMFlag = cli.BoolFlag{
    39  		Name:  "sputnikvm",
    40  		Usage: "Use SputnikVM Ethereum Virtual Machine implementation",
    41  	}
    42  	DataDirFlag = DirectoryFlag{
    43  		Name:  "data-dir,datadir",
    44  		Usage: "Data directory for the databases and keystore",
    45  		Value: DirectoryString{common.DefaultDataDir()},
    46  	}
    47  	KeyStoreDirFlag = DirectoryFlag{
    48  		Name:  "keystore",
    49  		Usage: "Directory path for the keystore",
    50  	}
    51  	ChainIdentityFlag = cli.StringFlag{
    52  		Name:  "chain",
    53  		Usage: `Chain identifier (default='mainnet', test='morden') or path to JSON chain configuration file (eg './path/to/chain.json').`,
    54  		Value: core.DefaultConfigMainnet.Identity,
    55  	}
    56  	NetworkIdFlag = cli.IntFlag{
    57  		Name:  "network-id, networkid",
    58  		Usage: "Network identifier (integer: 1=Homestead, 2=Morden)",
    59  		Value: eth.NetworkId,
    60  	}
    61  	TestNetFlag = cli.BoolFlag{
    62  		Name:  "testnet",
    63  		Usage: "[Use: --chain=morden] Morden network: pre-configured test network with modified starting nonces (replay protection)",
    64  	}
    65  	DevModeFlag = cli.BoolFlag{
    66  		Name:  "dev",
    67  		Usage: "Developer mode: pre-configured private network with several debugging flags",
    68  	}
    69  	NodeNameFlag = cli.StringFlag{
    70  		Name:  "identity,name",
    71  		Usage: "Custom node name",
    72  		Value: "",
    73  	}
    74  	NatspecEnabledFlag = cli.BoolFlag{
    75  		Name:  "natspec",
    76  		Usage: "Enable NatSpec confirmation notice",
    77  	}
    78  	DocRootFlag = DirectoryFlag{
    79  		Name:  "doc-root,docroot",
    80  		Usage: "Document Root for HTTPClient file scheme",
    81  		Value: DirectoryString{common.HomeDir()},
    82  	}
    83  	CacheFlag = cli.IntFlag{
    84  		Name:  "cache",
    85  		Usage: "Megabytes of memory allocated to internal caching (min 16MB / database forced)",
    86  		Value: 1024,
    87  	}
    88  	BlockchainVersionFlag = cli.IntFlag{
    89  		Name:  "blockchain-version,blockchainversion",
    90  		Usage: "Blockchain version (integer)",
    91  		Value: core.BlockChainVersion,
    92  	}
    93  	FastSyncFlag = cli.BoolFlag{
    94  		Name:  "fast",
    95  		Usage: "Enable fast syncing through state downloads",
    96  	}
    97  	LightKDFFlag = cli.BoolFlag{
    98  		Name:  "light-kdf,lightkdf",
    99  		Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength",
   100  	}
   101  	AddrTxIndexFlag = cli.BoolFlag{
   102  		Name:  "atxi,add-tx-index",
   103  		Usage: "Toggle indexes for transactions by address. Pre-existing chaindata can be indexed with command 'atxi-build'",
   104  	}
   105  	AddrTxIndexAutoBuildFlag = cli.BoolFlag{
   106  		Name:  "atxi.autobuild,atxi.auto-build",
   107  		Usage: "Begins automatic concurrent indexes building process that runs alongside a normally running geth.",
   108  	}
   109  	// Network Split settings
   110  	ETFChain = cli.BoolFlag{
   111  		Name:  "etf",
   112  		Usage: "Updates the chain rules to use the ETF hard-fork blockchain",
   113  	}
   114  	// Miner settings
   115  	// TODO Refactor CPU vs GPU mining flags
   116  	MiningEnabledFlag = cli.BoolFlag{
   117  		Name:  "mine",
   118  		Usage: "Enable mining",
   119  	}
   120  	MinerThreadsFlag = cli.IntFlag{
   121  		Name:  "miner-threads,minerthreads",
   122  		Usage: "Number of CPU threads to use for mining",
   123  		Value: runtime.NumCPU(),
   124  	}
   125  	MiningGPUFlag = cli.StringFlag{
   126  		Name:  "miner-gpus,minergpus",
   127  		Usage: "List of GPUs to use for mining (e.g. '0,1' will use the first two GPUs found)",
   128  		Value: "",
   129  	}
   130  	TargetGasLimitFlag = cli.StringFlag{
   131  		Name:  "target-gas-limit,targetgaslimit",
   132  		Usage: "Target gas limit sets the artificial target gas floor for the blocks to mine",
   133  		Value: core.TargetGasLimit.String(),
   134  	}
   135  	AutoDAGFlag = cli.BoolFlag{
   136  		Name:  "auto-dag,autodag",
   137  		Usage: "Enable automatic DAG pregeneration",
   138  	}
   139  	EtherbaseFlag = cli.StringFlag{
   140  		Name:  "etherbase",
   141  		Usage: "Public address for block mining rewards (default = first account created)",
   142  		Value: "0",
   143  	}
   144  	GasPriceFlag = cli.StringFlag{
   145  		Name:  "gas-price,gasprice",
   146  		Usage: "Minimal gas price to accept for mining a transactions",
   147  		Value: new(big.Int).Mul(big.NewInt(20), common.Shannon).String(),
   148  	}
   149  	ExtraDataFlag = cli.StringFlag{
   150  		Name:  "extra-data,extradata",
   151  		Usage: "Freeform header field set by the miner",
   152  	}
   153  	// Account settings
   154  	UnlockedAccountFlag = cli.StringFlag{
   155  		Name:  "unlock",
   156  		Usage: "Comma separated list of accounts to unlock",
   157  		Value: "",
   158  	}
   159  	PasswordFileFlag = cli.StringFlag{
   160  		Name:  "password",
   161  		Usage: "Password file to use for non-inteactive password input",
   162  		Value: "",
   163  	}
   164  	// logging and debug settings
   165  	NeckbeardFlag = cli.BoolFlag{
   166  		Name:  "neckbeard",
   167  		Usage: "Use verbose->stderr defaults for logging (verbosity=5,log-status='sync=60')",
   168  	}
   169  	VerbosityFlag = cli.IntFlag{
   170  		Name:  "verbosity",
   171  		Usage: "Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=core, 5=debug, 6=detail",
   172  		Value: glog.DefaultVerbosity,
   173  	}
   174  	DisplayFlag = cli.IntFlag{
   175  		Name:  "display",
   176  		Usage: "Display verbosity: 0=silent, 1=basics, 2=status, 3=status+events",
   177  		Value: glog.DefaultDisplay,
   178  	}
   179  	DisplayFormatFlag = cli.StringFlag{
   180  		Name:  "display-fmt",
   181  		Usage: "Display format (experimental). Current possible values are [basic|green|dash|gitlike].",
   182  		Value: "basic",
   183  	}
   184  	VModuleFlag = cli.StringFlag{
   185  		Name:  "vmodule",
   186  		Usage: "Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=6,p2p=5)",
   187  		Value: "",
   188  	}
   189  	LogDirFlag = cli.StringFlag{
   190  		Name:  "log-dir,logdir",
   191  		Usage: "Directory in which to write log files",
   192  		Value: filepath.Join(common.DefaultDataDir(), "<chain>", glog.DefaultLogDirName),
   193  	}
   194  	LogMaxSizeFlag = cli.StringFlag{
   195  		Name:  "log-max-size,log-maxsize",
   196  		Usage: "Maximum size of a single log file (in bytes)",
   197  		Value: "30M",
   198  	}
   199  	LogMinSizeFlag = cli.StringFlag{
   200  		Name:  "log-min-size,log-minsize",
   201  		Usage: "Minimum size of a log file, to be considered for log-rotation (in bytes)",
   202  		Value: "0",
   203  	}
   204  	LogMaxTotalSizeFlag = cli.StringFlag{
   205  		Name:  "log-total-max-size,log-totalmaxsize",
   206  		Usage: "Maximum total size of all (current and archived) log files (in bytes)",
   207  		Value: "0",
   208  	}
   209  	LogIntervalFlag = cli.StringFlag{
   210  		Name:  "log-rotation-interval",
   211  		Usage: "Log rotation interval, one of values: never, hourly, daily, weekly, monthly",
   212  		Value: "hourly",
   213  	}
   214  	LogMaxAgeFlag = cli.StringFlag{
   215  		Name:  "log-max-age,log-maxage",
   216  		Usage: "Maximum age of the oldest log file, valid time units: h, d, w (hours, days, weeks)",
   217  		Value: "0",
   218  	}
   219  	LogCompressFlag = cli.BoolTFlag{
   220  		Name:  "log-compress,log-gzip",
   221  		Usage: "Enable/disable GZIP compression of archived log files (enabled by default)",
   222  	}
   223  	LogStatusFlag = cli.StringFlag{
   224  		Name:  "log-status",
   225  		Usage: `Configure interval-based status logs: comma-separated list of <pattern>=<interval>. Use 'off' or '0' to disable.`,
   226  		Value: defaultStatusLog,
   227  	}
   228  	MLogFlag = cli.StringFlag{
   229  		Name:  "mlog",
   230  		Usage: "Set machine-readable log format: [plain|kv|json|off]",
   231  		Value: "off",
   232  	}
   233  	MLogDirFlag = DirectoryFlag{
   234  		Name:  "mlog-dir",
   235  		Usage: "Directory in which to write machine log files",
   236  		Value: DirectoryString{filepath.Join(common.DefaultDataDir(), "mainnet", "mlogs")},
   237  	}
   238  	MLogComponentsFlag = cli.StringFlag{
   239  		Name: "mlog-components",
   240  		Usage: `Set machine-readable logging components, comma-separated. 
   241  	Use a '!'-prefix to disabled listed components instead.`,
   242  		Value: "blockchain,txpool,downloader,fetcher,discover,server,state,headerchain,miner,client,wire",
   243  	}
   244  	BacktraceAtFlag = cli.GenericFlag{
   245  		Name:  "backtrace",
   246  		Usage: "Request a stack trace at a specific logging statement (e.g. \"block.go:271\")",
   247  		Value: glog.GetTraceLocation(),
   248  	}
   249  	MetricsFlag = cli.StringFlag{
   250  		Name:  "metrics",
   251  		Usage: "Enables metrics reporting. When the value is a path, either relative or absolute, then a log is written to the respective file.",
   252  		Value: "",
   253  	}
   254  	FakePoWFlag = cli.BoolFlag{
   255  		Name:  "fake-pow, fakepow",
   256  		Usage: "Disables proof-of-work verification",
   257  	}
   258  
   259  	// RPC settings
   260  	RPCEnabledFlag = cli.BoolFlag{
   261  		Name:  "rpc",
   262  		Usage: "Enable the HTTP-RPC server",
   263  	}
   264  	RPCListenAddrFlag = cli.StringFlag{
   265  		Name:  "rpc-addr,rpcaddr",
   266  		Usage: "HTTP-RPC server listening interface",
   267  		Value: common.DefaultHTTPHost,
   268  	}
   269  	RPCPortFlag = cli.IntFlag{
   270  		Name:  "rpc-port,rpcport",
   271  		Usage: "HTTP-RPC server listening port",
   272  		Value: common.DefaultHTTPPort,
   273  	}
   274  	RPCCORSDomainFlag = cli.StringFlag{
   275  		Name:  "rpc-cors-domain,rpccorsdomain",
   276  		Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)",
   277  		Value: "",
   278  	}
   279  	RPCApiFlag = cli.StringFlag{
   280  		Name:  "rpc-api,rpcapi",
   281  		Usage: "API's offered over the HTTP-RPC interface",
   282  		Value: rpc.DefaultHTTPApis,
   283  	}
   284  	IPCDisabledFlag = cli.BoolFlag{
   285  		Name:  "ipc-disable,ipcdisable",
   286  		Usage: "Disable the IPC-RPC server",
   287  	}
   288  	IPCApiFlag = cli.StringFlag{
   289  		Name:  "ipc-api,ipcapi",
   290  		Usage: "API's offered over the IPC-RPC interface",
   291  		Value: rpc.DefaultIPCApis,
   292  	}
   293  	IPCPathFlag = DirectoryFlag{
   294  		Name:  "ipc-path,ipcpath",
   295  		Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)",
   296  		Value: DirectoryString{common.DefaultIPCSocket},
   297  	}
   298  	WSEnabledFlag = cli.BoolFlag{
   299  		Name:  "ws",
   300  		Usage: "Enable the WS-RPC server",
   301  	}
   302  	WSListenAddrFlag = cli.StringFlag{
   303  		Name:  "ws-addr,wsaddr",
   304  		Usage: "WS-RPC server listening interface",
   305  		Value: common.DefaultWSHost,
   306  	}
   307  	WSPortFlag = cli.IntFlag{
   308  		Name:  "ws-port,wsport",
   309  		Usage: "WS-RPC server listening port",
   310  		Value: common.DefaultWSPort,
   311  	}
   312  	WSApiFlag = cli.StringFlag{
   313  		Name:  "ws-api,wsapi",
   314  		Usage: "API's offered over the WS-RPC interface",
   315  		Value: rpc.DefaultHTTPApis,
   316  	}
   317  	WSAllowedOriginsFlag = cli.StringFlag{
   318  		Name:  "ws-origins,wsorigins",
   319  		Usage: "Origins from which to accept websockets requests",
   320  		Value: "",
   321  	}
   322  	ExecFlag = cli.StringFlag{
   323  		Name:  "exec",
   324  		Usage: "Execute JavaScript statement (only in combination with console/attach)",
   325  		Value: "",
   326  	}
   327  	PreloadJSFlag = cli.StringFlag{
   328  		Name:  "preload",
   329  		Usage: "Comma separated list of JavaScript files to preload into the console",
   330  		Value: "",
   331  	}
   332  
   333  	// Network Settings
   334  	MaxPeersFlag = cli.IntFlag{
   335  		Name:  "max-peers,maxpeers",
   336  		Usage: "Maximum number of network peers (network disabled if set to 0)",
   337  		Value: 25,
   338  	}
   339  	MaxPendingPeersFlag = cli.IntFlag{
   340  		Name:  "max-pend-peers,maxpendpeers",
   341  		Usage: "Maximum number of pending connection attempts (defaults used if set to 0)",
   342  		Value: 0,
   343  	}
   344  	ListenPortFlag = cli.IntFlag{
   345  		Name:  "port",
   346  		Usage: "Network listening port",
   347  		Value: 30303,
   348  	}
   349  	BootnodesFlag = cli.StringFlag{
   350  		Name:  "bootnodes",
   351  		Usage: "Comma separated enode URLs for P2P discovery bootstrap",
   352  		Value: "",
   353  	}
   354  	NodeKeyFileFlag = cli.StringFlag{
   355  		Name:  "nodekey",
   356  		Usage: "P2P node key file",
   357  	}
   358  	NodeKeyHexFlag = cli.StringFlag{
   359  		Name:  "nodekey-hex,nodekeyhex",
   360  		Usage: "P2P node key as hex (for testing)",
   361  	}
   362  	NATFlag = cli.StringFlag{
   363  		Name:  "nat",
   364  		Usage: "NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)",
   365  		Value: "any",
   366  	}
   367  	NoDiscoverFlag = cli.BoolFlag{
   368  		Name:  "no-discover,nodiscover",
   369  		Usage: "Disables the peer discovery mechanism (manual peer addition)",
   370  	}
   371  	WhisperEnabledFlag = cli.BoolFlag{
   372  		Name:  "shh",
   373  		Usage: "Enable Whisper",
   374  	}
   375  	// ATM the url is left to the user and deployment to
   376  	JSpathFlag = cli.StringFlag{
   377  		Name:  "js-path,jspath",
   378  		Usage: "JavaScript root path for `loadScript` and document root for `admin.httpGet`",
   379  		Value: ".",
   380  	}
   381  	SolcPathFlag = cli.StringFlag{
   382  		Name:  "solc",
   383  		Usage: "Solidity compiler command to be used",
   384  		Value: "solc",
   385  	}
   386  
   387  	// Gas price oracle settings
   388  	GpoMinGasPriceFlag = cli.StringFlag{
   389  		Name:  "gpo-min,gpomin",
   390  		Usage: "Minimum suggested gas price",
   391  		Value: new(big.Int).Mul(big.NewInt(20), common.Shannon).String(),
   392  	}
   393  	GpoMaxGasPriceFlag = cli.StringFlag{
   394  		Name:  "gpo-max,gpomax",
   395  		Usage: "Maximum suggested gas price",
   396  		Value: new(big.Int).Mul(big.NewInt(500), common.Shannon).String(),
   397  	}
   398  	GpoFullBlockRatioFlag = cli.IntFlag{
   399  		Name:  "gpo-full,gpofull",
   400  		Usage: "Full block threshold for gas price calculation (%)",
   401  		Value: 80,
   402  	}
   403  	GpobaseStepDownFlag = cli.IntFlag{
   404  		Name:  "gpo-base-down,gpobasedown",
   405  		Usage: "Suggested gas price base step down ratio (1/1000)",
   406  		Value: 10,
   407  	}
   408  	GpobaseStepUpFlag = cli.IntFlag{
   409  		Name:  "gpo-base-up,gpobaseup",
   410  		Usage: "Suggested gas price base step up ratio (1/1000)",
   411  		Value: 100,
   412  	}
   413  	GpobaseCorrectionFactorFlag = cli.IntFlag{
   414  		Name:  "gpo-base-cf,gpobasecf",
   415  		Usage: "Suggested gas price base correction factor (%)",
   416  		Value: 110,
   417  	}
   418  	Unused1 = cli.BoolFlag{
   419  		Name:  "oppose-dao-fork",
   420  		Usage: "Use classic blockchain (always set, flag is unused and exists for compatibility only)",
   421  	}
   422  )
   423  
   424  // aliasableName check global vars for aliases flag and directoryFlag names.
   425  // These can be "comma,sep-arated", and ensures that if one is set (and/or not the other),
   426  // only one var will be returned and it will be decided in order of appearance.
   427  func aliasableName(commaSeparatedName string, ctx *cli.Context) string {
   428  	names := strings.Split(commaSeparatedName, ",")
   429  	returnName := names[0] // first name as default
   430  	last := len(names) - 1
   431  	// for in reverse, so that we prioritize the first appearing
   432  	for i := last; i >= 0; i-- {
   433  		if ctx.GlobalIsSet(strings.TrimSpace(names[i])) {
   434  			returnName = names[i]
   435  		}
   436  	}
   437  	return returnName
   438  }