cmd: golint fixes

This commit is contained in:
Mike Kinney 2019-12-09 20:59:32 -08:00
parent 77c0dc13f1
commit 231be4fde8
5 changed files with 181 additions and 17 deletions

View file

@ -137,7 +137,7 @@ var (
utils.RinkebyFlag, utils.RinkebyFlag,
utils.GoerliFlag, utils.GoerliFlag,
utils.VMEnableDebugFlag, utils.VMEnableDebugFlag,
utils.NetworkIdFlag, utils.NetworkIDFlag,
utils.EthStatsURLFlag, utils.EthStatsURLFlag,
utils.FakePoWFlag, utils.FakePoWFlag,
utils.NoCompactionFlag, utils.NoCompactionFlag,
@ -253,7 +253,7 @@ func main() {
// This function should be called before launching devp2p stack. // This function should be called before launching devp2p stack.
func prepare(ctx *cli.Context) { func prepare(ctx *cli.Context) {
// If we're a full node on mainnet without --cache specified, bump default cache allowance // If we're a full node on mainnet without --cache specified, bump default cache allowance
if ctx.GlobalString(utils.SyncModeFlag.Name) != "light" && !ctx.GlobalIsSet(utils.CacheFlag.Name) && !ctx.GlobalIsSet(utils.NetworkIdFlag.Name) { if ctx.GlobalString(utils.SyncModeFlag.Name) != "light" && !ctx.GlobalIsSet(utils.CacheFlag.Name) && !ctx.GlobalIsSet(utils.NetworkIDFlag.Name) {
// Make sure we're not on any supported preconfigured testnet either // Make sure we're not on any supported preconfigured testnet either
if !ctx.GlobalIsSet(utils.TestnetFlag.Name) && !ctx.GlobalIsSet(utils.RinkebyFlag.Name) && !ctx.GlobalIsSet(utils.GoerliFlag.Name) && !ctx.GlobalIsSet(utils.DeveloperFlag.Name) { if !ctx.GlobalIsSet(utils.TestnetFlag.Name) && !ctx.GlobalIsSet(utils.RinkebyFlag.Name) && !ctx.GlobalIsSet(utils.GoerliFlag.Name) && !ctx.GlobalIsSet(utils.DeveloperFlag.Name) {
// Nope, we're really on mainnet. Bump that cache up! // Nope, we're really on mainnet. Bump that cache up!

View file

@ -71,7 +71,7 @@ var AppHelpFlagGroups = []flagGroup{
utils.KeyStoreDirFlag, utils.KeyStoreDirFlag,
utils.NoUSBFlag, utils.NoUSBFlag,
utils.SmartCardDaemonPathFlag, utils.SmartCardDaemonPathFlag,
utils.NetworkIdFlag, utils.NetworkIDFlag,
utils.TestnetFlag, utils.TestnetFlag,
utils.RinkebyFlag, utils.RinkebyFlag,
utils.GoerliFlag, utils.GoerliFlag,

View file

@ -63,6 +63,7 @@ func Fatalf(format string, args ...interface{}) {
os.Exit(1) os.Exit(1)
} }
// StartNode starts the node
func StartNode(stack *node.Node) { func StartNode(stack *node.Node) {
if err := stack.Start(); err != nil { if err := stack.Start(); err != nil {
Fatalf("Error starting protocol stack: %v", err) Fatalf("Error starting protocol stack: %v", err)
@ -85,6 +86,7 @@ func StartNode(stack *node.Node) {
}() }()
} }
// ImportChain imports the blockchain
func ImportChain(chain *core.BlockChain, fn string) error { func ImportChain(chain *core.BlockChain, fn string) error {
// Watch for Ctrl-C while the import is running. // Watch for Ctrl-C while the import is running.
// If a signal is received, the import will stop at the next batch. // If a signal is received, the import will stop at the next batch.

View file

@ -30,22 +30,23 @@ import (
"gopkg.in/urfave/cli.v1" "gopkg.in/urfave/cli.v1"
) )
// Custom type which is registered in the flags library which cli uses for // DirectoryString is a custom type which is registered in the flags library
// argument parsing. This allows us to expand Value to an absolute path when // which cli uses for argument parsing. This allows us to expand Value to
// the argument is parsed // an absolute path when the argument is parsed
type DirectoryString string type DirectoryString string
func (s *DirectoryString) String() string { func (s *DirectoryString) String() string {
return string(*s) return string(*s)
} }
// Set sets the value
func (s *DirectoryString) Set(value string) error { func (s *DirectoryString) Set(value string) error {
*s = DirectoryString(expandPath(value)) *s = DirectoryString(expandPath(value))
return nil return nil
} }
// Custom cli.Flag type which expand the received string to an absolute path. // DirectoryFlag is a custom cli.Flag type which expand the received string
// e.g. ~/.ethereum -> /home/username/.ethereum // to an absolute path. e.g. ~/.ethereum -> /home/username/.ethereum
type DirectoryFlag struct { type DirectoryFlag struct {
Name string Name string
Value DirectoryString Value DirectoryString
@ -57,7 +58,7 @@ func (f DirectoryFlag) String() string {
return cli.FlagStringer(f) return cli.FlagStringer(f)
} }
// called by cli library, grabs variable from environment (if in env) // Apply is called by cli library, grabs variable from environment (if in env)
// and adds variable to flag set for parsing. // and adds variable to flag set for parsing.
func (f DirectoryFlag) Apply(set *flag.FlagSet) { func (f DirectoryFlag) Apply(set *flag.FlagSet) {
eachName(f.Name, func(name string) { eachName(f.Name, func(name string) {
@ -65,10 +66,12 @@ func (f DirectoryFlag) Apply(set *flag.FlagSet) {
}) })
} }
// GetName retuns the name
func (f DirectoryFlag) GetName() string { func (f DirectoryFlag) GetName() string {
return f.Name return f.Name
} }
// Set sets the value
func (f *DirectoryFlag) Set(value string) { func (f *DirectoryFlag) Set(value string) {
f.Value.Set(value) f.Value.Set(value)
} }
@ -81,6 +84,7 @@ func eachName(longName string, fn func(string)) {
} }
} }
// TextMarshaler provides an interface for marshalling/unmarshalling
type TextMarshaler interface { type TextMarshaler interface {
encoding.TextMarshaler encoding.TextMarshaler
encoding.TextUnmarshaler encoding.TextUnmarshaler
@ -111,6 +115,7 @@ type TextMarshalerFlag struct {
EnvVar string EnvVar string
} }
// GetName returns the name
func (f TextMarshalerFlag) GetName() string { func (f TextMarshalerFlag) GetName() string {
return f.Name return f.Name
} }
@ -119,6 +124,7 @@ func (f TextMarshalerFlag) String() string {
return cli.FlagStringer(f) return cli.FlagStringer(f)
} }
// Apply sets the value for each flag
func (f TextMarshalerFlag) Apply(set *flag.FlagSet) { func (f TextMarshalerFlag) Apply(set *flag.FlagSet) {
eachName(f.Name, func(name string) { eachName(f.Name, func(name string) {
set.Var(textMarshalerVal{f.Value}, f.Name, f.Usage) set.Var(textMarshalerVal{f.Value}, f.Name, f.Usage)
@ -162,6 +168,7 @@ func (b *bigValue) Set(s string) error {
return nil return nil
} }
// GetName returns the name
func (f BigFlag) GetName() string { func (f BigFlag) GetName() string {
return f.Name return f.Name
} }
@ -170,6 +177,7 @@ func (f BigFlag) String() string {
return cli.FlagStringer(f) return cli.FlagStringer(f)
} }
// Apply sets the value for each flag
func (f BigFlag) Apply(set *flag.FlagSet) { func (f BigFlag) Apply(set *flag.FlagSet) {
eachName(f.Name, func(name string) { eachName(f.Name, func(name string) {
set.Var((*bigValue)(f.Value), f.Name, f.Usage) set.Var((*bigValue)(f.Value), f.Name, f.Usage)

View file

@ -67,6 +67,7 @@ import (
) )
var ( var (
// CommandHelpTemplate is a templated string for command help
CommandHelpTemplate = `{{.cmd.Name}}{{if .cmd.Subcommands}} command{{end}}{{if .cmd.Flags}} [command options]{{end}} [arguments...] CommandHelpTemplate = `{{.cmd.Name}}{{if .cmd.Subcommands}} command{{end}}{{if .cmd.Flags}} [command options]{{end}} [arguments...]
{{if .cmd.Description}}{{.cmd.Description}} {{if .cmd.Description}}{{.cmd.Description}}
{{end}}{{if .cmd.Subcommands}} {{end}}{{if .cmd.Subcommands}}
@ -78,6 +79,7 @@ SUBCOMMANDS:
{{end}} {{end}}
{{end}}{{end}}` {{end}}{{end}}`
// OriginCommandHelpTemplate is a templated string for sub commands
OriginCommandHelpTemplate = `{{.Name}}{{if .Subcommands}} command{{end}}{{if .Flags}} [command options]{{end}} [arguments...] OriginCommandHelpTemplate = `{{.Name}}{{if .Subcommands}} command{{end}}{{if .Flags}} [command options]{{end}} [arguments...]
{{if .Description}}{{.Description}} {{if .Description}}{{.Description}}
{{end}}{{if .Subcommands}} {{end}}{{if .Subcommands}}
@ -137,528 +139,656 @@ func printHelp(out io.Writer, templ string, data interface{}) {
// are the same for all commands. // are the same for all commands.
var ( var (
// General settings // General settings
// DataDirFlag is the data directory for the databases and keystore
DataDirFlag = DirectoryFlag{ DataDirFlag = DirectoryFlag{
Name: "datadir", Name: "datadir",
Usage: "Data directory for the databases and keystore", Usage: "Data directory for the databases and keystore",
Value: DirectoryString(node.DefaultDataDir()), Value: DirectoryString(node.DefaultDataDir()),
} }
// AncientFlag is the data directory for the ancient chain segments
AncientFlag = DirectoryFlag{ AncientFlag = DirectoryFlag{
Name: "datadir.ancient", Name: "datadir.ancient",
Usage: "Data directory for ancient chain segments (default = inside chaindata)", Usage: "Data directory for ancient chain segments (default = inside chaindata)",
} }
// KeyStoreDirFlag is the directory for the keystore
KeyStoreDirFlag = DirectoryFlag{ KeyStoreDirFlag = DirectoryFlag{
Name: "keystore", Name: "keystore",
Usage: "Directory for the keystore (default = inside the datadir)", Usage: "Directory for the keystore (default = inside the datadir)",
} }
// NoUSBFlag disables monitoring for and managing USB hardware wallets
NoUSBFlag = cli.BoolFlag{ NoUSBFlag = cli.BoolFlag{
Name: "nousb", Name: "nousb",
Usage: "Disables monitoring for and managing USB hardware wallets", Usage: "Disables monitoring for and managing USB hardware wallets",
} }
// SmartCardDaemonPathFlag is the path to the smartcard daemon (pcscd) socket file
SmartCardDaemonPathFlag = cli.StringFlag{ SmartCardDaemonPathFlag = cli.StringFlag{
Name: "pcscdpath", Name: "pcscdpath",
Usage: "Path to the smartcard daemon (pcscd) socket file", Usage: "Path to the smartcard daemon (pcscd) socket file",
Value: pcsclite.PCSCDSockName, Value: pcsclite.PCSCDSockName,
} }
NetworkIdFlag = cli.Uint64Flag{ // NetworkIDFlag is the network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby)
NetworkIDFlag = cli.Uint64Flag{
Name: "networkid", Name: "networkid",
Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby)", Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby)",
Value: eth.DefaultConfig.NetworkId, Value: eth.DefaultConfig.NetworkId,
} }
// TestnetFlag is to use the Ropsten network: pre-configured proof-of-work test network
TestnetFlag = cli.BoolFlag{ TestnetFlag = cli.BoolFlag{
Name: "testnet", Name: "testnet",
Usage: "Ropsten network: pre-configured proof-of-work test network", Usage: "Ropsten network: pre-configured proof-of-work test network",
} }
// RinkebyFlag is to use the Rinkeby network: pre-configured proof-of-authority test network
RinkebyFlag = cli.BoolFlag{ RinkebyFlag = cli.BoolFlag{
Name: "rinkeby", Name: "rinkeby",
Usage: "Rinkeby network: pre-configured proof-of-authority test network", Usage: "Rinkeby network: pre-configured proof-of-authority test network",
} }
// GoerliFlag is to use the Görli network: pre-configured proof-of-authority test network
GoerliFlag = cli.BoolFlag{ GoerliFlag = cli.BoolFlag{
Name: "goerli", Name: "goerli",
Usage: "Görli network: pre-configured proof-of-authority test network", Usage: "Görli network: pre-configured proof-of-authority test network",
} }
// DeveloperFlag is to use an ephemeral proof-of-authority network with a pre-funded developer account, mining enabled
DeveloperFlag = cli.BoolFlag{ DeveloperFlag = cli.BoolFlag{
Name: "dev", Name: "dev",
Usage: "Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled", Usage: "Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled",
} }
// DeveloperPeriodFlag is to specify the block period to use in developer mode (0 = mine only if transaction pending)
DeveloperPeriodFlag = cli.IntFlag{ DeveloperPeriodFlag = cli.IntFlag{
Name: "dev.period", Name: "dev.period",
Usage: "Block period to use in developer mode (0 = mine only if transaction pending)", Usage: "Block period to use in developer mode (0 = mine only if transaction pending)",
} }
// IdentityFlag is to use a custom node name
IdentityFlag = cli.StringFlag{ IdentityFlag = cli.StringFlag{
Name: "identity", Name: "identity",
Usage: "Custom node name", Usage: "Custom node name",
} }
// DocRootFlag is the document root for HTTPClient file scheme
DocRootFlag = DirectoryFlag{ DocRootFlag = DirectoryFlag{
Name: "docroot", Name: "docroot",
Usage: "Document Root for HTTPClient file scheme", Usage: "Document Root for HTTPClient file scheme",
Value: DirectoryString(homeDir()), Value: DirectoryString(homeDir()),
} }
// ExitWhenSyncedFlag specifies to exit after block synchronisation completes
ExitWhenSyncedFlag = cli.BoolFlag{ ExitWhenSyncedFlag = cli.BoolFlag{
Name: "exitwhensynced", Name: "exitwhensynced",
Usage: "Exits after block synchronisation completes", Usage: "Exits after block synchronisation completes",
} }
// IterativeOutputFlag will print streaming JSON iteratively, delimited by newlines
IterativeOutputFlag = cli.BoolFlag{ IterativeOutputFlag = cli.BoolFlag{
Name: "iterative", Name: "iterative",
Usage: "Print streaming JSON iteratively, delimited by newlines", Usage: "Print streaming JSON iteratively, delimited by newlines",
} }
// ExcludeStorageFlag specifies to exclude storage entries (save db lookups)
ExcludeStorageFlag = cli.BoolFlag{ ExcludeStorageFlag = cli.BoolFlag{
Name: "nostorage", Name: "nostorage",
Usage: "Exclude storage entries (save db lookups)", Usage: "Exclude storage entries (save db lookups)",
} }
// IncludeIncompletesFlag specifies to include accounts for which we don't have the address (missing preimage)
IncludeIncompletesFlag = cli.BoolFlag{ IncludeIncompletesFlag = cli.BoolFlag{
Name: "incompletes", Name: "incompletes",
Usage: "Include accounts for which we don't have the address (missing preimage)", Usage: "Include accounts for which we don't have the address (missing preimage)",
} }
// ExcludeCodeFlag is to exclude contract code (save db lookups)
ExcludeCodeFlag = cli.BoolFlag{ ExcludeCodeFlag = cli.BoolFlag{
Name: "nocode", Name: "nocode",
Usage: "Exclude contract code (save db lookups)", Usage: "Exclude contract code (save db lookups)",
} }
defaultSyncMode = eth.DefaultConfig.SyncMode defaultSyncMode = eth.DefaultConfig.SyncMode
// SyncModeFlag is the blockchain sync mode ("fast", "full", or "light")
SyncModeFlag = TextMarshalerFlag{ SyncModeFlag = TextMarshalerFlag{
Name: "syncmode", Name: "syncmode",
Usage: `Blockchain sync mode ("fast", "full", or "light")`, Usage: `Blockchain sync mode ("fast", "full", or "light")`,
Value: &defaultSyncMode, Value: &defaultSyncMode,
} }
// GCModeFlag is the blockchain garbage collection mode ("full", "archive")
GCModeFlag = cli.StringFlag{ GCModeFlag = cli.StringFlag{
Name: "gcmode", Name: "gcmode",
Usage: `Blockchain garbage collection mode ("full", "archive")`, Usage: `Blockchain garbage collection mode ("full", "archive")`,
Value: "full", Value: "full",
} }
// LightKDFFlag specifies to reduce key-derivation RAM & CPU usage at some expense of KDF strength"
LightKDFFlag = cli.BoolFlag{ LightKDFFlag = cli.BoolFlag{
Name: "lightkdf", Name: "lightkdf",
Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength", Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength",
} }
// WhitelistFlag is a comma separated block number-to-hash mappings to enforce (<number>=<hash>)
WhitelistFlag = cli.StringFlag{ WhitelistFlag = cli.StringFlag{
Name: "whitelist", Name: "whitelist",
Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>)", Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>)",
} }
// OverrideIstanbulFlag specifies to manually specify Istanbul fork-block, overriding the bundled setting
OverrideIstanbulFlag = cli.Uint64Flag{ OverrideIstanbulFlag = cli.Uint64Flag{
Name: "override.istanbul", Name: "override.istanbul",
Usage: "Manually specify Istanbul fork-block, overriding the bundled setting", Usage: "Manually specify Istanbul fork-block, overriding the bundled setting",
} }
// OverrideMuirGlacierFlag is to manually specify Muir Glacier fork-block, overriding the bundled setting
OverrideMuirGlacierFlag = cli.Uint64Flag{ OverrideMuirGlacierFlag = cli.Uint64Flag{
Name: "override.muirglacier", Name: "override.muirglacier",
Usage: "Manually specify Muir Glacier fork-block, overriding the bundled setting", Usage: "Manually specify Muir Glacier fork-block, overriding the bundled setting",
} }
// Light server and client settings // LightLegacyServFlag is for light server and client settings
LightLegacyServFlag = cli.IntFlag{ // Deprecated in favor of light.serve, remove in 2021 LightLegacyServFlag = cli.IntFlag{ // Deprecated in favor of light.serve, remove in 2021
Name: "lightserv", Name: "lightserv",
Usage: "Maximum percentage of time allowed for serving LES requests (deprecated, use --light.serve)", Usage: "Maximum percentage of time allowed for serving LES requests (deprecated, use --light.serve)",
Value: eth.DefaultConfig.LightServ, Value: eth.DefaultConfig.LightServ,
} }
// LightServeFlag specifies the maximum percentage of time allowed for serving LES requests (multi-threaded processing allows values over 100)
LightServeFlag = cli.IntFlag{ LightServeFlag = cli.IntFlag{
Name: "light.serve", Name: "light.serve",
Usage: "Maximum percentage of time allowed for serving LES requests (multi-threaded processing allows values over 100)", Usage: "Maximum percentage of time allowed for serving LES requests (multi-threaded processing allows values over 100)",
Value: eth.DefaultConfig.LightServ, Value: eth.DefaultConfig.LightServ,
} }
// LightIngressFlag specifies the incoming bandwidth limit for serving light clients (kilobytes/sec, 0 = unlimited)
LightIngressFlag = cli.IntFlag{ LightIngressFlag = cli.IntFlag{
Name: "light.ingress", Name: "light.ingress",
Usage: "Incoming bandwidth limit for serving light clients (kilobytes/sec, 0 = unlimited)", Usage: "Incoming bandwidth limit for serving light clients (kilobytes/sec, 0 = unlimited)",
Value: eth.DefaultConfig.LightIngress, Value: eth.DefaultConfig.LightIngress,
} }
// LightEgressFlag specifies the outgoing bandwidth limit for serving light clients (kilobytes/sec, 0 = unlimited)
LightEgressFlag = cli.IntFlag{ LightEgressFlag = cli.IntFlag{
Name: "light.egress", Name: "light.egress",
Usage: "Outgoing bandwidth limit for serving light clients (kilobytes/sec, 0 = unlimited)", Usage: "Outgoing bandwidth limit for serving light clients (kilobytes/sec, 0 = unlimited)",
Value: eth.DefaultConfig.LightEgress, Value: eth.DefaultConfig.LightEgress,
} }
// LightLegacyPeersFlag specifies the maximum number of light clients to serve, or light servers to attach to (deprecated, use --light.maxpeers)
LightLegacyPeersFlag = cli.IntFlag{ // Deprecated in favor of light.maxpeers, remove in 2021 LightLegacyPeersFlag = cli.IntFlag{ // Deprecated in favor of light.maxpeers, remove in 2021
Name: "lightpeers", Name: "lightpeers",
Usage: "Maximum number of light clients to serve, or light servers to attach to (deprecated, use --light.maxpeers)", Usage: "Maximum number of light clients to serve, or light servers to attach to (deprecated, use --light.maxpeers)",
Value: eth.DefaultConfig.LightPeers, Value: eth.DefaultConfig.LightPeers,
} }
// LightMaxPeersFlag specifies the maximum number of light clients to serve, or light servers to attach to
LightMaxPeersFlag = cli.IntFlag{ LightMaxPeersFlag = cli.IntFlag{
Name: "light.maxpeers", Name: "light.maxpeers",
Usage: "Maximum number of light clients to serve, or light servers to attach to", Usage: "Maximum number of light clients to serve, or light servers to attach to",
Value: eth.DefaultConfig.LightPeers, Value: eth.DefaultConfig.LightPeers,
} }
// UltraLightServersFlag specifies the list of trusted ultra-light servers
UltraLightServersFlag = cli.StringFlag{ UltraLightServersFlag = cli.StringFlag{
Name: "ulc.servers", Name: "ulc.servers",
Usage: "List of trusted ultra-light servers", Usage: "List of trusted ultra-light servers",
Value: strings.Join(eth.DefaultConfig.UltraLightServers, ","), Value: strings.Join(eth.DefaultConfig.UltraLightServers, ","),
} }
// UltraLightFractionFlag specifies the minimum % of trusted ultra-light servers required to announce a new head
UltraLightFractionFlag = cli.IntFlag{ UltraLightFractionFlag = cli.IntFlag{
Name: "ulc.fraction", Name: "ulc.fraction",
Usage: "Minimum % of trusted ultra-light servers required to announce a new head", Usage: "Minimum % of trusted ultra-light servers required to announce a new head",
Value: eth.DefaultConfig.UltraLightFraction, Value: eth.DefaultConfig.UltraLightFraction,
} }
// UltraLightOnlyAnnounceFlag specifies that ultra light server sends announcements only
UltraLightOnlyAnnounceFlag = cli.BoolFlag{ UltraLightOnlyAnnounceFlag = cli.BoolFlag{
Name: "ulc.onlyannounce", Name: "ulc.onlyannounce",
Usage: "Ultra light server sends announcements only", Usage: "Ultra light server sends announcements only",
} }
// Ethash settings // Ethash settings
// EthashCacheDirFlag specifies the directory to store the ethash verification caches (default = inside the datadir)
EthashCacheDirFlag = DirectoryFlag{ EthashCacheDirFlag = DirectoryFlag{
Name: "ethash.cachedir", Name: "ethash.cachedir",
Usage: "Directory to store the ethash verification caches (default = inside the datadir)", Usage: "Directory to store the ethash verification caches (default = inside the datadir)",
} }
// EthashCachesInMemoryFlag specifies the number of recent ethash caches to keep in memory (16MB each)
EthashCachesInMemoryFlag = cli.IntFlag{ EthashCachesInMemoryFlag = cli.IntFlag{
Name: "ethash.cachesinmem", Name: "ethash.cachesinmem",
Usage: "Number of recent ethash caches to keep in memory (16MB each)", Usage: "Number of recent ethash caches to keep in memory (16MB each)",
Value: eth.DefaultConfig.Ethash.CachesInMem, Value: eth.DefaultConfig.Ethash.CachesInMem,
} }
// EthashCachesOnDiskFlag specifies the number of recent ethash caches to keep on disk (16MB each)
EthashCachesOnDiskFlag = cli.IntFlag{ EthashCachesOnDiskFlag = cli.IntFlag{
Name: "ethash.cachesondisk", Name: "ethash.cachesondisk",
Usage: "Number of recent ethash caches to keep on disk (16MB each)", Usage: "Number of recent ethash caches to keep on disk (16MB each)",
Value: eth.DefaultConfig.Ethash.CachesOnDisk, Value: eth.DefaultConfig.Ethash.CachesOnDisk,
} }
// EthashDatasetDirFlag specifies the directory to store the ethash mining DAGs
EthashDatasetDirFlag = DirectoryFlag{ EthashDatasetDirFlag = DirectoryFlag{
Name: "ethash.dagdir", Name: "ethash.dagdir",
Usage: "Directory to store the ethash mining DAGs", Usage: "Directory to store the ethash mining DAGs",
Value: DirectoryString(eth.DefaultConfig.Ethash.DatasetDir), Value: DirectoryString(eth.DefaultConfig.Ethash.DatasetDir),
} }
// EthashDatasetsInMemoryFlag specifies the number of recent ethash mining DAGs to keep in memory (1+GB each)
EthashDatasetsInMemoryFlag = cli.IntFlag{ EthashDatasetsInMemoryFlag = cli.IntFlag{
Name: "ethash.dagsinmem", Name: "ethash.dagsinmem",
Usage: "Number of recent ethash mining DAGs to keep in memory (1+GB each)", Usage: "Number of recent ethash mining DAGs to keep in memory (1+GB each)",
Value: eth.DefaultConfig.Ethash.DatasetsInMem, Value: eth.DefaultConfig.Ethash.DatasetsInMem,
} }
// EthashDatasetsOnDiskFlag specifies the number of recent ethash mining DAGs to keep on disk (1+GB each)
EthashDatasetsOnDiskFlag = cli.IntFlag{ EthashDatasetsOnDiskFlag = cli.IntFlag{
Name: "ethash.dagsondisk", Name: "ethash.dagsondisk",
Usage: "Number of recent ethash mining DAGs to keep on disk (1+GB each)", Usage: "Number of recent ethash mining DAGs to keep on disk (1+GB each)",
Value: eth.DefaultConfig.Ethash.DatasetsOnDisk, Value: eth.DefaultConfig.Ethash.DatasetsOnDisk,
} }
// Transaction pool settings // Transaction pool settings
// TxPoolLocalsFlag is a comma separated accounts to treat as locals (no flush, priority inclusion)
TxPoolLocalsFlag = cli.StringFlag{ TxPoolLocalsFlag = cli.StringFlag{
Name: "txpool.locals", Name: "txpool.locals",
Usage: "Comma separated accounts to treat as locals (no flush, priority inclusion)", Usage: "Comma separated accounts to treat as locals (no flush, priority inclusion)",
} }
// TxPoolNoLocalsFlag disables price exemptions for locally submitted transactions
TxPoolNoLocalsFlag = cli.BoolFlag{ TxPoolNoLocalsFlag = cli.BoolFlag{
Name: "txpool.nolocals", Name: "txpool.nolocals",
Usage: "Disables price exemptions for locally submitted transactions", Usage: "Disables price exemptions for locally submitted transactions",
} }
// TxPoolJournalFlag specifies the disk journal for local transaction to survive node restarts
TxPoolJournalFlag = cli.StringFlag{ TxPoolJournalFlag = cli.StringFlag{
Name: "txpool.journal", Name: "txpool.journal",
Usage: "Disk journal for local transaction to survive node restarts", Usage: "Disk journal for local transaction to survive node restarts",
Value: core.DefaultTxPoolConfig.Journal, Value: core.DefaultTxPoolConfig.Journal,
} }
// TxPoolRejournalFlag specifies the time interval to regenerate the local transaction journal
TxPoolRejournalFlag = cli.DurationFlag{ TxPoolRejournalFlag = cli.DurationFlag{
Name: "txpool.rejournal", Name: "txpool.rejournal",
Usage: "Time interval to regenerate the local transaction journal", Usage: "Time interval to regenerate the local transaction journal",
Value: core.DefaultTxPoolConfig.Rejournal, Value: core.DefaultTxPoolConfig.Rejournal,
} }
// TxPoolPriceLimitFlag specifies the minimum gas price limit to enforce for acceptance into the pool
TxPoolPriceLimitFlag = cli.Uint64Flag{ TxPoolPriceLimitFlag = cli.Uint64Flag{
Name: "txpool.pricelimit", Name: "txpool.pricelimit",
Usage: "Minimum gas price limit to enforce for acceptance into the pool", Usage: "Minimum gas price limit to enforce for acceptance into the pool",
Value: eth.DefaultConfig.TxPool.PriceLimit, Value: eth.DefaultConfig.TxPool.PriceLimit,
} }
// TxPoolPriceBumpFlag specifies the price bump percentage to replace an already existing transaction
TxPoolPriceBumpFlag = cli.Uint64Flag{ TxPoolPriceBumpFlag = cli.Uint64Flag{
Name: "txpool.pricebump", Name: "txpool.pricebump",
Usage: "Price bump percentage to replace an already existing transaction", Usage: "Price bump percentage to replace an already existing transaction",
Value: eth.DefaultConfig.TxPool.PriceBump, Value: eth.DefaultConfig.TxPool.PriceBump,
} }
// TxPoolAccountSlotsFlag specifies the minimum number of executable transaction slots guaranteed per account
TxPoolAccountSlotsFlag = cli.Uint64Flag{ TxPoolAccountSlotsFlag = cli.Uint64Flag{
Name: "txpool.accountslots", Name: "txpool.accountslots",
Usage: "Minimum number of executable transaction slots guaranteed per account", Usage: "Minimum number of executable transaction slots guaranteed per account",
Value: eth.DefaultConfig.TxPool.AccountSlots, Value: eth.DefaultConfig.TxPool.AccountSlots,
} }
// TxPoolGlobalSlotsFlag specifies the maximum number of executable transaction slots for all accounts
TxPoolGlobalSlotsFlag = cli.Uint64Flag{ TxPoolGlobalSlotsFlag = cli.Uint64Flag{
Name: "txpool.globalslots", Name: "txpool.globalslots",
Usage: "Maximum number of executable transaction slots for all accounts", Usage: "Maximum number of executable transaction slots for all accounts",
Value: eth.DefaultConfig.TxPool.GlobalSlots, Value: eth.DefaultConfig.TxPool.GlobalSlots,
} }
// TxPoolAccountQueueFlag specifies the maximum number of non-executable transaction slots permitted per account
TxPoolAccountQueueFlag = cli.Uint64Flag{ TxPoolAccountQueueFlag = cli.Uint64Flag{
Name: "txpool.accountqueue", Name: "txpool.accountqueue",
Usage: "Maximum number of non-executable transaction slots permitted per account", Usage: "Maximum number of non-executable transaction slots permitted per account",
Value: eth.DefaultConfig.TxPool.AccountQueue, Value: eth.DefaultConfig.TxPool.AccountQueue,
} }
// TxPoolGlobalQueueFlag specifies the maximum number of non-executable transaction slots for all accounts
TxPoolGlobalQueueFlag = cli.Uint64Flag{ TxPoolGlobalQueueFlag = cli.Uint64Flag{
Name: "txpool.globalqueue", Name: "txpool.globalqueue",
Usage: "Maximum number of non-executable transaction slots for all accounts", Usage: "Maximum number of non-executable transaction slots for all accounts",
Value: eth.DefaultConfig.TxPool.GlobalQueue, Value: eth.DefaultConfig.TxPool.GlobalQueue,
} }
// TxPoolLifetimeFlag specifies the maximum amount of time non-executable transaction are queued
TxPoolLifetimeFlag = cli.DurationFlag{ TxPoolLifetimeFlag = cli.DurationFlag{
Name: "txpool.lifetime", Name: "txpool.lifetime",
Usage: "Maximum amount of time non-executable transaction are queued", Usage: "Maximum amount of time non-executable transaction are queued",
Value: eth.DefaultConfig.TxPool.Lifetime, Value: eth.DefaultConfig.TxPool.Lifetime,
} }
// Performance tuning settings // Performance tuning settings
// CacheFlag specifies the megabytes of memory allocated to internal caching (default = 4096 mainnet full node, 128 light mode)
CacheFlag = cli.IntFlag{ CacheFlag = cli.IntFlag{
Name: "cache", Name: "cache",
Usage: "Megabytes of memory allocated to internal caching (default = 4096 mainnet full node, 128 light mode)", Usage: "Megabytes of memory allocated to internal caching (default = 4096 mainnet full node, 128 light mode)",
Value: 1024, Value: 1024,
} }
// CacheDatabaseFlag specifies the percentage of cache memory allowance to use for database io
CacheDatabaseFlag = cli.IntFlag{ CacheDatabaseFlag = cli.IntFlag{
Name: "cache.database", Name: "cache.database",
Usage: "Percentage of cache memory allowance to use for database io", Usage: "Percentage of cache memory allowance to use for database io",
Value: 50, Value: 50,
} }
// CacheTrieFlag specifies the percentage of cache memory allowance to use for trie caching (default = 25% full mode, 50% archive mode)
CacheTrieFlag = cli.IntFlag{ CacheTrieFlag = cli.IntFlag{
Name: "cache.trie", Name: "cache.trie",
Usage: "Percentage of cache memory allowance to use for trie caching (default = 25% full mode, 50% archive mode)", Usage: "Percentage of cache memory allowance to use for trie caching (default = 25% full mode, 50% archive mode)",
Value: 25, Value: 25,
} }
// CacheGCFlag specifies the percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)
CacheGCFlag = cli.IntFlag{ CacheGCFlag = cli.IntFlag{
Name: "cache.gc", Name: "cache.gc",
Usage: "Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)", Usage: "Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)",
Value: 25, Value: 25,
} }
// CacheNoPrefetchFlag will disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data)
CacheNoPrefetchFlag = cli.BoolFlag{ CacheNoPrefetchFlag = cli.BoolFlag{
Name: "cache.noprefetch", Name: "cache.noprefetch",
Usage: "Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data)", Usage: "Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data)",
} }
// Miner settings // Miner settings
// MiningEnabledFlag will enable mining
MiningEnabledFlag = cli.BoolFlag{ MiningEnabledFlag = cli.BoolFlag{
Name: "mine", Name: "mine",
Usage: "Enable mining", Usage: "Enable mining",
} }
// MinerThreadsFlag specifies the number of CPU threads to use for mining
MinerThreadsFlag = cli.IntFlag{ MinerThreadsFlag = cli.IntFlag{
Name: "miner.threads", Name: "miner.threads",
Usage: "Number of CPU threads to use for mining", Usage: "Number of CPU threads to use for mining",
Value: 0, Value: 0,
} }
// MinerLegacyThreadsFlag specifies the number of CPU threads to use for mining (deprecated, use --miner.threads)
MinerLegacyThreadsFlag = cli.IntFlag{ MinerLegacyThreadsFlag = cli.IntFlag{
Name: "minerthreads", Name: "minerthreads",
Usage: "Number of CPU threads to use for mining (deprecated, use --miner.threads)", Usage: "Number of CPU threads to use for mining (deprecated, use --miner.threads)",
Value: 0, Value: 0,
} }
// MinerNotifyFlag is a comma separated HTTP URL list to notify of new work packages
MinerNotifyFlag = cli.StringFlag{ MinerNotifyFlag = cli.StringFlag{
Name: "miner.notify", Name: "miner.notify",
Usage: "Comma separated HTTP URL list to notify of new work packages", Usage: "Comma separated HTTP URL list to notify of new work packages",
} }
// MinerGasTargetFlag specifies the target gas floor for mined blocks
MinerGasTargetFlag = cli.Uint64Flag{ MinerGasTargetFlag = cli.Uint64Flag{
Name: "miner.gastarget", Name: "miner.gastarget",
Usage: "Target gas floor for mined blocks", Usage: "Target gas floor for mined blocks",
Value: eth.DefaultConfig.Miner.GasFloor, Value: eth.DefaultConfig.Miner.GasFloor,
} }
// MinerLegacyGasTargetFlag specifies the target gas floor for mined blocks (deprecated, use --miner.gastarget)
MinerLegacyGasTargetFlag = cli.Uint64Flag{ MinerLegacyGasTargetFlag = cli.Uint64Flag{
Name: "targetgaslimit", Name: "targetgaslimit",
Usage: "Target gas floor for mined blocks (deprecated, use --miner.gastarget)", Usage: "Target gas floor for mined blocks (deprecated, use --miner.gastarget)",
Value: eth.DefaultConfig.Miner.GasFloor, Value: eth.DefaultConfig.Miner.GasFloor,
} }
// MinerGasLimitFlag specifies the target gas ceiling for mined blocks
MinerGasLimitFlag = cli.Uint64Flag{ MinerGasLimitFlag = cli.Uint64Flag{
Name: "miner.gaslimit", Name: "miner.gaslimit",
Usage: "Target gas ceiling for mined blocks", Usage: "Target gas ceiling for mined blocks",
Value: eth.DefaultConfig.Miner.GasCeil, Value: eth.DefaultConfig.Miner.GasCeil,
} }
// MinerGasPriceFlag specifies the minimum gas price for mining a transaction
MinerGasPriceFlag = BigFlag{ MinerGasPriceFlag = BigFlag{
Name: "miner.gasprice", Name: "miner.gasprice",
Usage: "Minimum gas price for mining a transaction", Usage: "Minimum gas price for mining a transaction",
Value: eth.DefaultConfig.Miner.GasPrice, Value: eth.DefaultConfig.Miner.GasPrice,
} }
// MinerLegacyGasPriceFlag specifies the minimum gas price for mining a transaction (deprecated, use --miner.gasprice)
MinerLegacyGasPriceFlag = BigFlag{ MinerLegacyGasPriceFlag = BigFlag{
Name: "gasprice", Name: "gasprice",
Usage: "Minimum gas price for mining a transaction (deprecated, use --miner.gasprice)", Usage: "Minimum gas price for mining a transaction (deprecated, use --miner.gasprice)",
Value: eth.DefaultConfig.Miner.GasPrice, Value: eth.DefaultConfig.Miner.GasPrice,
} }
// MinerEtherbaseFlag specifies the public address for block mining rewards (default = first account)
MinerEtherbaseFlag = cli.StringFlag{ MinerEtherbaseFlag = cli.StringFlag{
Name: "miner.etherbase", Name: "miner.etherbase",
Usage: "Public address for block mining rewards (default = first account)", Usage: "Public address for block mining rewards (default = first account)",
Value: "0", Value: "0",
} }
// MinerLegacyEtherbaseFlag specicies the public address for block mining rewards (default = first account, deprecated, use --miner.etherbase)
MinerLegacyEtherbaseFlag = cli.StringFlag{ MinerLegacyEtherbaseFlag = cli.StringFlag{
Name: "etherbase", Name: "etherbase",
Usage: "Public address for block mining rewards (default = first account, deprecated, use --miner.etherbase)", Usage: "Public address for block mining rewards (default = first account, deprecated, use --miner.etherbase)",
Value: "0", Value: "0",
} }
// MinerExtraDataFlag specifies the block extra data set by the miner (default = client version)
MinerExtraDataFlag = cli.StringFlag{ MinerExtraDataFlag = cli.StringFlag{
Name: "miner.extradata", Name: "miner.extradata",
Usage: "Block extra data set by the miner (default = client version)", Usage: "Block extra data set by the miner (default = client version)",
} }
// MinerLegacyExtraDataFlag specifies the block extra data set by the miner (default = client version, deprecated, use --miner.extradata)
MinerLegacyExtraDataFlag = cli.StringFlag{ MinerLegacyExtraDataFlag = cli.StringFlag{
Name: "extradata", Name: "extradata",
Usage: "Block extra data set by the miner (default = client version, deprecated, use --miner.extradata)", Usage: "Block extra data set by the miner (default = client version, deprecated, use --miner.extradata)",
} }
// MinerRecommitIntervalFlag specifies the time interval to recreate the block being mined
MinerRecommitIntervalFlag = cli.DurationFlag{ MinerRecommitIntervalFlag = cli.DurationFlag{
Name: "miner.recommit", Name: "miner.recommit",
Usage: "Time interval to recreate the block being mined", Usage: "Time interval to recreate the block being mined",
Value: eth.DefaultConfig.Miner.Recommit, Value: eth.DefaultConfig.Miner.Recommit,
} }
// MinerNoVerfiyFlag will disable remote sealing verification
MinerNoVerfiyFlag = cli.BoolFlag{ MinerNoVerfiyFlag = cli.BoolFlag{
Name: "miner.noverify", Name: "miner.noverify",
Usage: "Disable remote sealing verification", Usage: "Disable remote sealing verification",
} }
// Account settings // Account settings
// UnlockedAccountFlag specifies a comma separated list of accounts to unlock
UnlockedAccountFlag = cli.StringFlag{ UnlockedAccountFlag = cli.StringFlag{
Name: "unlock", Name: "unlock",
Usage: "Comma separated list of accounts to unlock", Usage: "Comma separated list of accounts to unlock",
Value: "", Value: "",
} }
// PasswordFileFlag specifies a password file to use for non-interactive password input
PasswordFileFlag = cli.StringFlag{ PasswordFileFlag = cli.StringFlag{
Name: "password", Name: "password",
Usage: "Password file to use for non-interactive password input", Usage: "Password file to use for non-interactive password input",
Value: "", Value: "",
} }
// ExternalSignerFlag specifies the external signer (url or path to ipc file)
ExternalSignerFlag = cli.StringFlag{ ExternalSignerFlag = cli.StringFlag{
Name: "signer", Name: "signer",
Usage: "External signer (url or path to ipc file)", Usage: "External signer (url or path to ipc file)",
Value: "", Value: "",
} }
// VMEnableDebugFlag will record information useful for VM and contract debugging
VMEnableDebugFlag = cli.BoolFlag{ VMEnableDebugFlag = cli.BoolFlag{
Name: "vmdebug", Name: "vmdebug",
Usage: "Record information useful for VM and contract debugging", Usage: "Record information useful for VM and contract debugging",
} }
// InsecureUnlockAllowedFlag will allow insecure account unlocking when account-related RPCs are exposed by http
InsecureUnlockAllowedFlag = cli.BoolFlag{ InsecureUnlockAllowedFlag = cli.BoolFlag{
Name: "allow-insecure-unlock", Name: "allow-insecure-unlock",
Usage: "Allow insecure account unlocking when account-related RPCs are exposed by http", Usage: "Allow insecure account unlocking when account-related RPCs are exposed by http",
} }
// RPCGlobalGasCap sets a cap on gas that can be used in eth_call/estimateGas
RPCGlobalGasCap = cli.Uint64Flag{ RPCGlobalGasCap = cli.Uint64Flag{
Name: "rpc.gascap", Name: "rpc.gascap",
Usage: "Sets a cap on gas that can be used in eth_call/estimateGas", Usage: "Sets a cap on gas that can be used in eth_call/estimateGas",
} }
// Logging and debug settings // Logging and debug settings
// EthStatsURLFlag sets the reporting URL of a ethstats service (nodename:secret@host:port)
EthStatsURLFlag = cli.StringFlag{ EthStatsURLFlag = cli.StringFlag{
Name: "ethstats", Name: "ethstats",
Usage: "Reporting URL of a ethstats service (nodename:secret@host:port)", Usage: "Reporting URL of a ethstats service (nodename:secret@host:port)",
} }
// FakePoWFlag disables proof-of-work verification
FakePoWFlag = cli.BoolFlag{ FakePoWFlag = cli.BoolFlag{
Name: "fakepow", Name: "fakepow",
Usage: "Disables proof-of-work verification", Usage: "Disables proof-of-work verification",
} }
// NoCompactionFlag disables db compaction after import
NoCompactionFlag = cli.BoolFlag{ NoCompactionFlag = cli.BoolFlag{
Name: "nocompaction", Name: "nocompaction",
Usage: "Disables db compaction after import", Usage: "Disables db compaction after import",
} }
// RPC settings // RPC settings
// IPCDisabledFlag disable the IPC-RPC server
IPCDisabledFlag = cli.BoolFlag{ IPCDisabledFlag = cli.BoolFlag{
Name: "ipcdisable", Name: "ipcdisable",
Usage: "Disable the IPC-RPC server", Usage: "Disable the IPC-RPC server",
} }
// IPCPathFlag specifies the filename for IPC socket/pipe within the datadir (explicit paths escape it)
IPCPathFlag = DirectoryFlag{ IPCPathFlag = DirectoryFlag{
Name: "ipcpath", Name: "ipcpath",
Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)", Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)",
} }
// RPCEnabledFlag will enable the HTTP-RPC server
RPCEnabledFlag = cli.BoolFlag{ RPCEnabledFlag = cli.BoolFlag{
Name: "rpc", Name: "rpc",
Usage: "Enable the HTTP-RPC server", Usage: "Enable the HTTP-RPC server",
} }
// RPCListenAddrFlag specifies the HTTP-RPC server listening interface
RPCListenAddrFlag = cli.StringFlag{ RPCListenAddrFlag = cli.StringFlag{
Name: "rpcaddr", Name: "rpcaddr",
Usage: "HTTP-RPC server listening interface", Usage: "HTTP-RPC server listening interface",
Value: node.DefaultHTTPHost, Value: node.DefaultHTTPHost,
} }
// RPCPortFlag specifies the HTTP-RPC server listening port
RPCPortFlag = cli.IntFlag{ RPCPortFlag = cli.IntFlag{
Name: "rpcport", Name: "rpcport",
Usage: "HTTP-RPC server listening port", Usage: "HTTP-RPC server listening port",
Value: node.DefaultHTTPPort, Value: node.DefaultHTTPPort,
} }
// RPCCORSDomainFlag specifies a comma separated list of domains from which to accept cross origin requests (browser enforced)
RPCCORSDomainFlag = cli.StringFlag{ RPCCORSDomainFlag = cli.StringFlag{
Name: "rpccorsdomain", Name: "rpccorsdomain",
Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)", Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)",
Value: "", Value: "",
} }
// RPCVirtualHostsFlag specifies a comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
RPCVirtualHostsFlag = cli.StringFlag{ RPCVirtualHostsFlag = cli.StringFlag{
Name: "rpcvhosts", Name: "rpcvhosts",
Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.", Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.",
Value: strings.Join(node.DefaultConfig.HTTPVirtualHosts, ","), Value: strings.Join(node.DefaultConfig.HTTPVirtualHosts, ","),
} }
// RPCApiFlag specifies the API's offered over the HTTP-RPC interface
RPCApiFlag = cli.StringFlag{ RPCApiFlag = cli.StringFlag{
Name: "rpcapi", Name: "rpcapi",
Usage: "API's offered over the HTTP-RPC interface", Usage: "API's offered over the HTTP-RPC interface",
Value: "", Value: "",
} }
// WSEnabledFlag will enable the WS-RPC server
WSEnabledFlag = cli.BoolFlag{ WSEnabledFlag = cli.BoolFlag{
Name: "ws", Name: "ws",
Usage: "Enable the WS-RPC server", Usage: "Enable the WS-RPC server",
} }
// WSListenAddrFlag specifies the WS-RPC server listening interface
WSListenAddrFlag = cli.StringFlag{ WSListenAddrFlag = cli.StringFlag{
Name: "wsaddr", Name: "wsaddr",
Usage: "WS-RPC server listening interface", Usage: "WS-RPC server listening interface",
Value: node.DefaultWSHost, Value: node.DefaultWSHost,
} }
// WSPortFlag specifies the WS-RPC server listening port
WSPortFlag = cli.IntFlag{ WSPortFlag = cli.IntFlag{
Name: "wsport", Name: "wsport",
Usage: "WS-RPC server listening port", Usage: "WS-RPC server listening port",
Value: node.DefaultWSPort, Value: node.DefaultWSPort,
} }
// WSApiFlag specifies the API's offered over the WS-RPC interface
WSApiFlag = cli.StringFlag{ WSApiFlag = cli.StringFlag{
Name: "wsapi", Name: "wsapi",
Usage: "API's offered over the WS-RPC interface", Usage: "API's offered over the WS-RPC interface",
Value: "", Value: "",
} }
// WSAllowedOriginsFlag specifies the origins from which to accept websockets requests
WSAllowedOriginsFlag = cli.StringFlag{ WSAllowedOriginsFlag = cli.StringFlag{
Name: "wsorigins", Name: "wsorigins",
Usage: "Origins from which to accept websockets requests", Usage: "Origins from which to accept websockets requests",
Value: "", Value: "",
} }
// GraphQLEnabledFlag will enable the GraphQL server
GraphQLEnabledFlag = cli.BoolFlag{ GraphQLEnabledFlag = cli.BoolFlag{
Name: "graphql", Name: "graphql",
Usage: "Enable the GraphQL server", Usage: "Enable the GraphQL server",
} }
// GraphQLListenAddrFlag specifies the GraphQL server listening interface
GraphQLListenAddrFlag = cli.StringFlag{ GraphQLListenAddrFlag = cli.StringFlag{
Name: "graphql.addr", Name: "graphql.addr",
Usage: "GraphQL server listening interface", Usage: "GraphQL server listening interface",
Value: node.DefaultGraphQLHost, Value: node.DefaultGraphQLHost,
} }
// GraphQLPortFlag specifies the GraphQL server listening port
GraphQLPortFlag = cli.IntFlag{ GraphQLPortFlag = cli.IntFlag{
Name: "graphql.port", Name: "graphql.port",
Usage: "GraphQL server listening port", Usage: "GraphQL server listening port",
Value: node.DefaultGraphQLPort, Value: node.DefaultGraphQLPort,
} }
// GraphQLCORSDomainFlag specifies a comma separated list of domains from which to accept cross origin requests (browser enforced)
GraphQLCORSDomainFlag = cli.StringFlag{ GraphQLCORSDomainFlag = cli.StringFlag{
Name: "graphql.corsdomain", Name: "graphql.corsdomain",
Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)", Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)",
Value: "", Value: "",
} }
// GraphQLVirtualHostsFlag specifies a comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
GraphQLVirtualHostsFlag = cli.StringFlag{ GraphQLVirtualHostsFlag = cli.StringFlag{
Name: "graphql.vhosts", Name: "graphql.vhosts",
Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.", Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.",
Value: strings.Join(node.DefaultConfig.GraphQLVirtualHosts, ","), Value: strings.Join(node.DefaultConfig.GraphQLVirtualHosts, ","),
} }
// ExecFlag specifies the execute JavaScript statement
ExecFlag = cli.StringFlag{ ExecFlag = cli.StringFlag{
Name: "exec", Name: "exec",
Usage: "Execute JavaScript statement", Usage: "Execute JavaScript statement",
} }
// PreloadJSFlag specifies a comma separated list of JavaScript files to preload into the console
PreloadJSFlag = cli.StringFlag{ PreloadJSFlag = cli.StringFlag{
Name: "preload", Name: "preload",
Usage: "Comma separated list of JavaScript files to preload into the console", Usage: "Comma separated list of JavaScript files to preload into the console",
} }
// Network Settings // Network Settings
// MaxPeersFlag specifies the maximum number of network peers (network disabled if set to 0)
MaxPeersFlag = cli.IntFlag{ MaxPeersFlag = cli.IntFlag{
Name: "maxpeers", Name: "maxpeers",
Usage: "Maximum number of network peers (network disabled if set to 0)", Usage: "Maximum number of network peers (network disabled if set to 0)",
Value: node.DefaultConfig.P2P.MaxPeers, Value: node.DefaultConfig.P2P.MaxPeers,
} }
// MaxPendingPeersFlag specifies the maximum number of pending connection attempts (defaults used if set to 0)
MaxPendingPeersFlag = cli.IntFlag{ MaxPendingPeersFlag = cli.IntFlag{
Name: "maxpendpeers", Name: "maxpendpeers",
Usage: "Maximum number of pending connection attempts (defaults used if set to 0)", Usage: "Maximum number of pending connection attempts (defaults used if set to 0)",
Value: node.DefaultConfig.P2P.MaxPendingPeers, Value: node.DefaultConfig.P2P.MaxPendingPeers,
} }
// ListenPortFlag specifies the network listening port
ListenPortFlag = cli.IntFlag{ ListenPortFlag = cli.IntFlag{
Name: "port", Name: "port",
Usage: "Network listening port", Usage: "Network listening port",
Value: 30303, Value: 30303,
} }
// BootnodesFlag specifies a comma separated enode URLs for P2P discovery bootstrap (set v4+v5 instead for light servers)
BootnodesFlag = cli.StringFlag{ BootnodesFlag = cli.StringFlag{
Name: "bootnodes", Name: "bootnodes",
Usage: "Comma separated enode URLs for P2P discovery bootstrap (set v4+v5 instead for light servers)", Usage: "Comma separated enode URLs for P2P discovery bootstrap (set v4+v5 instead for light servers)",
Value: "", Value: "",
} }
// BootnodesV4Flag specifies a comma separated enode URLs for P2P v4 discovery bootstrap (light server, full nodes)
BootnodesV4Flag = cli.StringFlag{ BootnodesV4Flag = cli.StringFlag{
Name: "bootnodesv4", Name: "bootnodesv4",
Usage: "Comma separated enode URLs for P2P v4 discovery bootstrap (light server, full nodes)", Usage: "Comma separated enode URLs for P2P v4 discovery bootstrap (light server, full nodes)",
Value: "", Value: "",
} }
// BootnodesV5Flag specifies a comma separated enode URLs for P2P v5 discovery bootstrap (light server, light nodes)
BootnodesV5Flag = cli.StringFlag{ BootnodesV5Flag = cli.StringFlag{
Name: "bootnodesv5", Name: "bootnodesv5",
Usage: "Comma separated enode URLs for P2P v5 discovery bootstrap (light server, light nodes)", Usage: "Comma separated enode URLs for P2P v5 discovery bootstrap (light server, light nodes)",
Value: "", Value: "",
} }
// NodeKeyFileFlag specifies the P2P node key file
NodeKeyFileFlag = cli.StringFlag{ NodeKeyFileFlag = cli.StringFlag{
Name: "nodekey", Name: "nodekey",
Usage: "P2P node key file", Usage: "P2P node key file",
} }
// NodeKeyHexFlag specifies the P2P node key as hex (for testing)
NodeKeyHexFlag = cli.StringFlag{ NodeKeyHexFlag = cli.StringFlag{
Name: "nodekeyhex", Name: "nodekeyhex",
Usage: "P2P node key as hex (for testing)", Usage: "P2P node key as hex (for testing)",
} }
// NATFlag specifies the NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)
NATFlag = cli.StringFlag{ NATFlag = cli.StringFlag{
Name: "nat", Name: "nat",
Usage: "NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)", Usage: "NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)",
Value: "any", Value: "any",
} }
// NoDiscoverFlag will disable the peer discovery mechanism (manual peer addition)
NoDiscoverFlag = cli.BoolFlag{ NoDiscoverFlag = cli.BoolFlag{
Name: "nodiscover", Name: "nodiscover",
Usage: "Disables the peer discovery mechanism (manual peer addition)", Usage: "Disables the peer discovery mechanism (manual peer addition)",
} }
// DiscoveryV5Flag will enable the experimental RLPx V5 (Topic Discovery) mechanism
DiscoveryV5Flag = cli.BoolFlag{ DiscoveryV5Flag = cli.BoolFlag{
Name: "v5disc", Name: "v5disc",
Usage: "Enables the experimental RLPx V5 (Topic Discovery) mechanism", Usage: "Enables the experimental RLPx V5 (Topic Discovery) mechanism",
} }
// NetrestrictFlag will restrict network communication to the given IP networks (CIDR masks)
NetrestrictFlag = cli.StringFlag{ NetrestrictFlag = cli.StringFlag{
Name: "netrestrict", Name: "netrestrict",
Usage: "Restricts network communication to the given IP networks (CIDR masks)", Usage: "Restricts network communication to the given IP networks (CIDR masks)",
} }
// JSpathFlag specifies the JavaScript root path for `loadScript'
// ATM the url is left to the user and deployment to // ATM the url is left to the user and deployment to
JSpathFlag = cli.StringFlag{ JSpathFlag = cli.StringFlag{
Name: "jspath", Name: "jspath",
@ -667,83 +797,103 @@ var (
} }
// Gas price oracle settings // Gas price oracle settings
// GpoBlocksFlag specifies the number of recent blocks to check for gas prices
GpoBlocksFlag = cli.IntFlag{ GpoBlocksFlag = cli.IntFlag{
Name: "gpoblocks", Name: "gpoblocks",
Usage: "Number of recent blocks to check for gas prices", Usage: "Number of recent blocks to check for gas prices",
Value: eth.DefaultConfig.GPO.Blocks, Value: eth.DefaultConfig.GPO.Blocks,
} }
// GpoPercentileFlag specifies the suggested gas price is the given percentile of a set of recent transaction gas prices
GpoPercentileFlag = cli.IntFlag{ GpoPercentileFlag = cli.IntFlag{
Name: "gpopercentile", Name: "gpopercentile",
Usage: "Suggested gas price is the given percentile of a set of recent transaction gas prices", Usage: "Suggested gas price is the given percentile of a set of recent transaction gas prices",
Value: eth.DefaultConfig.GPO.Percentile, Value: eth.DefaultConfig.GPO.Percentile,
} }
// WhisperEnabledFlag will enable Whisper
WhisperEnabledFlag = cli.BoolFlag{ WhisperEnabledFlag = cli.BoolFlag{
Name: "shh", Name: "shh",
Usage: "Enable Whisper", Usage: "Enable Whisper",
} }
// WhisperMaxMessageSizeFlag specifies the max message size accepted
WhisperMaxMessageSizeFlag = cli.IntFlag{ WhisperMaxMessageSizeFlag = cli.IntFlag{
Name: "shh.maxmessagesize", Name: "shh.maxmessagesize",
Usage: "Max message size accepted", Usage: "Max message size accepted",
Value: int(whisper.DefaultMaxMessageSize), Value: int(whisper.DefaultMaxMessageSize),
} }
// WhisperMinPOWFlag specifies the minimum POW accepted
WhisperMinPOWFlag = cli.Float64Flag{ WhisperMinPOWFlag = cli.Float64Flag{
Name: "shh.pow", Name: "shh.pow",
Usage: "Minimum POW accepted", Usage: "Minimum POW accepted",
Value: whisper.DefaultMinimumPoW, Value: whisper.DefaultMinimumPoW,
} }
// WhisperRestrictConnectionBetweenLightClientsFlag will restrict connection between two whisper light clients
WhisperRestrictConnectionBetweenLightClientsFlag = cli.BoolFlag{ WhisperRestrictConnectionBetweenLightClientsFlag = cli.BoolFlag{
Name: "shh.restrict-light", Name: "shh.restrict-light",
Usage: "Restrict connection between two whisper light clients", Usage: "Restrict connection between two whisper light clients",
} }
// Metrics flags // Metrics flags
// MetricsEnabledFlag will enable metrics collection and reporting
MetricsEnabledFlag = cli.BoolFlag{ MetricsEnabledFlag = cli.BoolFlag{
Name: "metrics", Name: "metrics",
Usage: "Enable metrics collection and reporting", Usage: "Enable metrics collection and reporting",
} }
// MetricsEnabledExpensiveFlag will enable expensive metrics collection and reporting
MetricsEnabledExpensiveFlag = cli.BoolFlag{ MetricsEnabledExpensiveFlag = cli.BoolFlag{
Name: "metrics.expensive", Name: "metrics.expensive",
Usage: "Enable expensive metrics collection and reporting", Usage: "Enable expensive metrics collection and reporting",
} }
// MetricsEnableInfluxDBFlag will enable metrics export/push to an external InfluxDB database
MetricsEnableInfluxDBFlag = cli.BoolFlag{ MetricsEnableInfluxDBFlag = cli.BoolFlag{
Name: "metrics.influxdb", Name: "metrics.influxdb",
Usage: "Enable metrics export/push to an external InfluxDB database", Usage: "Enable metrics export/push to an external InfluxDB database",
} }
// MetricsInfluxDBEndpointFlag specifies the InfluxDB API endpoint to report metrics to
MetricsInfluxDBEndpointFlag = cli.StringFlag{ MetricsInfluxDBEndpointFlag = cli.StringFlag{
Name: "metrics.influxdb.endpoint", Name: "metrics.influxdb.endpoint",
Usage: "InfluxDB API endpoint to report metrics to", Usage: "InfluxDB API endpoint to report metrics to",
Value: "http://localhost:8086", Value: "http://localhost:8086",
} }
// MetricsInfluxDBDatabaseFlag specifies the InfluxDB database name to push reported metrics to
MetricsInfluxDBDatabaseFlag = cli.StringFlag{ MetricsInfluxDBDatabaseFlag = cli.StringFlag{
Name: "metrics.influxdb.database", Name: "metrics.influxdb.database",
Usage: "InfluxDB database name to push reported metrics to", Usage: "InfluxDB database name to push reported metrics to",
Value: "geth", Value: "geth",
} }
// MetricsInfluxDBUsernameFlag specifies the username to authorize access to the database
MetricsInfluxDBUsernameFlag = cli.StringFlag{ MetricsInfluxDBUsernameFlag = cli.StringFlag{
Name: "metrics.influxdb.username", Name: "metrics.influxdb.username",
Usage: "Username to authorize access to the database", Usage: "Username to authorize access to the database",
Value: "test", Value: "test",
} }
// MetricsInfluxDBPasswordFlag specifies the password to authorize access to the database
MetricsInfluxDBPasswordFlag = cli.StringFlag{ MetricsInfluxDBPasswordFlag = cli.StringFlag{
Name: "metrics.influxdb.password", Name: "metrics.influxdb.password",
Usage: "Password to authorize access to the database", Usage: "Password to authorize access to the database",
Value: "test", Value: "test",
} }
// Tags are part of every measurement sent to InfluxDB. Queries on tags are faster in InfluxDB. // Tags are part of every measurement sent to InfluxDB. Queries on tags are faster in InfluxDB.
// For example `host` tag could be used so that we can group all nodes and average a measurement // For example `host` tag could be used so that we can group all nodes and average a measurement
// across all of them, but also so that we can select a specific node and inspect its measurements. // across all of them, but also so that we can select a specific node and inspect its measurements.
// https://docs.influxdata.com/influxdb/v1.4/concepts/key_concepts/#tag-key // https://docs.influxdata.com/influxdb/v1.4/concepts/key_concepts/#tag-key
// MetricsInfluxDBTagsFlag specifies a comma-separated InfluxDB tags (key/values) attached to all measurements
MetricsInfluxDBTagsFlag = cli.StringFlag{ MetricsInfluxDBTagsFlag = cli.StringFlag{
Name: "metrics.influxdb.tags", Name: "metrics.influxdb.tags",
Usage: "Comma-separated InfluxDB tags (key/values) attached to all measurements", Usage: "Comma-separated InfluxDB tags (key/values) attached to all measurements",
Value: "host=localhost", Value: "host=localhost",
} }
// EWASMInterpreterFlag specifies an external ewasm configuration (default = built-in interpreter)
EWASMInterpreterFlag = cli.StringFlag{ EWASMInterpreterFlag = cli.StringFlag{
Name: "vm.ewasm", Name: "vm.ewasm",
Usage: "External ewasm configuration (default = built-in interpreter)", Usage: "External ewasm configuration (default = built-in interpreter)",
Value: "", Value: "",
} }
// EVMInterpreterFlag specifies an external EVM configuration (default = built-in interpreter)
EVMInterpreterFlag = cli.StringFlag{ EVMInterpreterFlag = cli.StringFlag{
Name: "vm.evm", Name: "vm.evm",
Usage: "External EVM configuration (default = built-in interpreter)", Usage: "External EVM configuration (default = built-in interpreter)",
@ -1089,6 +1239,7 @@ func MakePasswordList(ctx *cli.Context) []string {
return lines return lines
} }
// SetP2PConfig sets the P2P configuration
func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) { func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
setNodeKey(ctx, cfg) setNodeKey(ctx, cfg)
setNAT(ctx, cfg) setNAT(ctx, cfg)
@ -1433,8 +1584,8 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
if ctx.GlobalIsSet(SyncModeFlag.Name) { if ctx.GlobalIsSet(SyncModeFlag.Name) {
cfg.SyncMode = *GlobalTextMarshaler(ctx, SyncModeFlag.Name).(*downloader.SyncMode) cfg.SyncMode = *GlobalTextMarshaler(ctx, SyncModeFlag.Name).(*downloader.SyncMode)
} }
if ctx.GlobalIsSet(NetworkIdFlag.Name) { if ctx.GlobalIsSet(NetworkIDFlag.Name) {
cfg.NetworkId = ctx.GlobalUint64(NetworkIdFlag.Name) cfg.NetworkId = ctx.GlobalUint64(NetworkIDFlag.Name)
} }
if ctx.GlobalIsSet(CacheFlag.Name) || ctx.GlobalIsSet(CacheDatabaseFlag.Name) { if ctx.GlobalIsSet(CacheFlag.Name) || ctx.GlobalIsSet(CacheDatabaseFlag.Name) {
cfg.DatabaseCache = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheDatabaseFlag.Name) / 100 cfg.DatabaseCache = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheDatabaseFlag.Name) / 100
@ -1481,22 +1632,22 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
// Override any default configs for hard coded networks. // Override any default configs for hard coded networks.
switch { switch {
case ctx.GlobalBool(TestnetFlag.Name): case ctx.GlobalBool(TestnetFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) { if !ctx.GlobalIsSet(NetworkIDFlag.Name) {
cfg.NetworkId = 3 cfg.NetworkId = 3
} }
cfg.Genesis = core.DefaultTestnetGenesisBlock() cfg.Genesis = core.DefaultTestnetGenesisBlock()
case ctx.GlobalBool(RinkebyFlag.Name): case ctx.GlobalBool(RinkebyFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) { if !ctx.GlobalIsSet(NetworkIDFlag.Name) {
cfg.NetworkId = 4 cfg.NetworkId = 4
} }
cfg.Genesis = core.DefaultRinkebyGenesisBlock() cfg.Genesis = core.DefaultRinkebyGenesisBlock()
case ctx.GlobalBool(GoerliFlag.Name): case ctx.GlobalBool(GoerliFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) { if !ctx.GlobalIsSet(NetworkIDFlag.Name) {
cfg.NetworkId = 5 cfg.NetworkId = 5
} }
cfg.Genesis = core.DefaultGoerliGenesisBlock() cfg.Genesis = core.DefaultGoerliGenesisBlock()
case ctx.GlobalBool(DeveloperFlag.Name): case ctx.GlobalBool(DeveloperFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) { if !ctx.GlobalIsSet(NetworkIDFlag.Name) {
cfg.NetworkId = 1337 cfg.NetworkId = 1337
} }
// Create new developer account or reuse existing one // Create new developer account or reuse existing one
@ -1593,6 +1744,7 @@ func RegisterGraphQLService(stack *node.Node, endpoint string, cors, vhosts []st
} }
} }
// SetupMetrics sets up the metrics
func SetupMetrics(ctx *cli.Context) { func SetupMetrics(ctx *cli.Context) {
if metrics.Enabled { if metrics.Enabled {
log.Info("Enabling metrics collection") log.Info("Enabling metrics collection")
@ -1614,6 +1766,7 @@ func SetupMetrics(ctx *cli.Context) {
} }
} }
// SplitTagsFlag splits the tagsflags and returns a map of keys and values
func SplitTagsFlag(tagsFlag string) map[string]string { func SplitTagsFlag(tagsFlag string) map[string]string {
tags := strings.Split(tagsFlag, ",") tags := strings.Split(tagsFlag, ",")
tagsMap := map[string]string{} tagsMap := map[string]string{}
@ -1648,6 +1801,7 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database {
return chainDb return chainDb
} }
// MakeGenesis will make a genesis block
func MakeGenesis(ctx *cli.Context) *core.Genesis { func MakeGenesis(ctx *cli.Context) *core.Genesis {
var genesis *core.Genesis var genesis *core.Genesis
switch { switch {