Documentation ¶
Overview ¶
Package utils contains internal helper functions for go-ethereum commands.
Index ¶
- Variables
- func CheckLegalese(datadir string)
- func ExportAppendChain(chainmgr *core.ChainManager, fn string, first uint64, last uint64) error
- func ExportChain(chainmgr *core.ChainManager, fn string) error
- func Fatalf(format string, args ...interface{})
- func FormatTransactionData(data string) []byte
- func ImportChain(chain *core.ChainManager, fn string) error
- func InitOlympic()
- func IpcSocketPath(ctx *cli.Context) (ipcpath string)
- func MakeAccountManager(ctx *cli.Context) *accounts.Manager
- func MakeChain(ctx *cli.Context) (chain *core.ChainManager, chainDb common.Database)
- func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config
- func MakeNAT(ctx *cli.Context) nat.Interface
- func MakeNodeKey(ctx *cli.Context) (key *ecdsa.PrivateKey)
- func NewApp(version, usage string) *cli.App
- func ParamToAddress(addr string, am *accounts.Manager) (addrHex string, err error)
- func PromptConfirm(prompt string) (bool, error)
- func PromptPassword(prompt string, warnTerm bool) (string, error)
- func SetupLogger(ctx *cli.Context)
- func SetupVM(ctx *cli.Context)
- func StartEthereum(ethereum *eth.Ethereum)
- func StartIPC(eth *eth.Ethereum, ctx *cli.Context) error
- func StartPProf(ctx *cli.Context)
- func StartRPC(eth *eth.Ethereum, ctx *cli.Context) error
- type DirectoryFlag
- type DirectoryString
Constants ¶
This section is empty.
Variables ¶
var ( // General settings DataDirFlag = DirectoryFlag{ Name: "datadir", Usage: "Data directory to be used", Value: DirectoryString{common.DefaultDataDir()}, } NetworkIdFlag = cli.IntFlag{ Name: "networkid", Usage: "Network Id (integer)", Value: eth.NetworkId, } BlockchainVersionFlag = cli.IntFlag{ Name: "blockchainversion", Usage: "Blockchain version (integer)", Value: core.BlockChainVersion, } GenesisNonceFlag = cli.IntFlag{ Name: "genesisnonce", Usage: "Sets the genesis nonce", Value: 42, } GenesisFileFlag = cli.StringFlag{ Name: "genesis", Usage: "Inserts/Overwrites the genesis block (json format)", } IdentityFlag = cli.StringFlag{ Name: "identity", Usage: "Custom node name", } NatspecEnabledFlag = cli.BoolFlag{ Name: "natspec", Usage: "Enable NatSpec confirmation notice", } CacheFlag = cli.IntFlag{ Name: "cache", Usage: "Megabytes of memory allocated to internal caching", Value: 0, } OlympicFlag = cli.BoolFlag{ Name: "olympic", Usage: "Use olympic style protocol", } // miner settings MinerThreadsFlag = cli.IntFlag{ Name: "minerthreads", Usage: "Number of miner threads", Value: runtime.NumCPU(), } MiningEnabledFlag = cli.BoolFlag{ Name: "mine", Usage: "Enable mining", } AutoDAGFlag = cli.BoolFlag{ Name: "autodag", Usage: "Enable automatic DAG pregeneration", } EtherbaseFlag = cli.StringFlag{ Name: "etherbase", Usage: "Public address for block mining rewards. By default the address first created is used", Value: "0", } GasPriceFlag = cli.StringFlag{ Name: "gasprice", Usage: "Sets the minimal gasprice when mining transactions", Value: new(big.Int).Mul(big.NewInt(50), common.Shannon).String(), } UnlockedAccountFlag = cli.StringFlag{ Name: "unlock", Usage: "Unlock the account given until this program exits (prompts for password). '--unlock n' unlocks the n-th account in order or creation.", Value: "", } PasswordFileFlag = cli.StringFlag{ Name: "password", Usage: "Path to password file to use with options and subcommands needing a password", Value: "", } // vm flags VMDebugFlag = cli.BoolFlag{ Name: "vmdebug", Usage: "Virtual Machine debug output", } VMForceJitFlag = cli.BoolFlag{ Name: "forcejit", Usage: "Force the JIT VM to take precedence", } VMJitCacheFlag = cli.IntFlag{ Name: "jitcache", Usage: "Amount of cached JIT VM programs", Value: 64, } VMEnableJitFlag = cli.BoolFlag{ Name: "jitvm", Usage: "Enable the JIT VM", } // logging and debug settings LogFileFlag = cli.StringFlag{ Name: "logfile", Usage: "Send log output to a file", } VerbosityFlag = cli.IntFlag{ Name: "verbosity", Usage: "Logging verbosity: 0-6 (0=silent, 1=error, 2=warn, 3=info, 4=core, 5=debug, 6=debug detail)", Value: int(logger.InfoLevel), } LogJSONFlag = cli.StringFlag{ Name: "logjson", Usage: "Send json structured log output to a file or '-' for standard output (default: no json output)", Value: "", } LogToStdErrFlag = cli.BoolFlag{ Name: "logtostderr", Usage: "Logs are written to standard error instead of to files.", } LogVModuleFlag = cli.GenericFlag{ Name: "vmodule", Usage: "The syntax of the argument is a comma-separated list of pattern=N, where pattern is a literal file name (minus the \".go\" suffix) or \"glob\" pattern and N is a log verbosity level.", Value: glog.GetVModule(), } BacktraceAtFlag = cli.GenericFlag{ Name: "backtrace_at", Usage: "If set to a file and line number (e.g., \"block.go:271\") holding a logging statement, a stack trace will be logged", Value: glog.GetTraceLocation(), } PProfEanbledFlag = cli.BoolFlag{ Name: "pprof", Usage: "Enable the profiling server on localhost", } PProfPortFlag = cli.IntFlag{ Name: "pprofport", Usage: "Port on which the profiler should listen", Value: 6060, } MetricsEnabledFlag = cli.BoolFlag{ Name: metrics.MetricsEnabledFlag, Usage: "Enables metrics collection and reporting", } // RPC settings RPCEnabledFlag = cli.BoolFlag{ Name: "rpc", Usage: "Enable the JSON-RPC server", } RPCListenAddrFlag = cli.StringFlag{ Name: "rpcaddr", Usage: "Listening address for the JSON-RPC server", Value: "127.0.0.1", } RPCPortFlag = cli.IntFlag{ Name: "rpcport", Usage: "Port on which the JSON-RPC server should listen", Value: 8545, } RPCCORSDomainFlag = cli.StringFlag{ Name: "rpccorsdomain", Usage: "Domain on which to send Access-Control-Allow-Origin header", Value: "", } RpcApiFlag = cli.StringFlag{ Name: "rpcapi", Usage: "Specify the API's which are offered over the HTTP RPC interface", Value: comms.DefaultHttpRpcApis, } IPCDisabledFlag = cli.BoolFlag{ Name: "ipcdisable", Usage: "Disable the IPC-RPC server", } IPCApiFlag = cli.StringFlag{ Name: "ipcapi", Usage: "Specify the API's which are offered over the IPC interface", Value: comms.DefaultIpcApis, } IPCPathFlag = DirectoryFlag{ Name: "ipcpath", Usage: "Filename for IPC socket/pipe", Value: DirectoryString{common.DefaultIpcPath()}, } ExecFlag = cli.StringFlag{ Name: "exec", Usage: "Execute javascript statement (only in combination with console/attach)", } // Network Settings MaxPeersFlag = cli.IntFlag{ Name: "maxpeers", Usage: "Maximum number of network peers (network disabled if set to 0)", Value: 25, } MaxPendingPeersFlag = cli.IntFlag{ Name: "maxpendpeers", Usage: "Maximum number of pending connection attempts (defaults used if set to 0)", Value: 0, } ListenPortFlag = cli.IntFlag{ Name: "port", Usage: "Network listening port", Value: 30303, } BootnodesFlag = cli.StringFlag{ Name: "bootnodes", Usage: "Space-separated enode URLs for p2p discovery bootstrap", Value: "", } NodeKeyFileFlag = cli.StringFlag{ Name: "nodekey", Usage: "P2P node key file", } NodeKeyHexFlag = cli.StringFlag{ Name: "nodekeyhex", Usage: "P2P node key as hex (for testing)", } NATFlag = cli.StringFlag{ Name: "nat", Usage: "NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)", Value: "any", } NoDiscoverFlag = cli.BoolFlag{ Name: "nodiscover", Usage: "Disables the peer discovery mechanism (manual peer addition)", } WhisperEnabledFlag = cli.BoolFlag{ Name: "shh", Usage: "Enable whisper", } // ATM the url is left to the user and deployment to JSpathFlag = cli.StringFlag{ Name: "jspath", Usage: "JS library path to be used with console and js subcommands", Value: ".", } SolcPathFlag = cli.StringFlag{ Name: "solc", Usage: "solidity compiler to be used", Value: "solc", } GpoMinGasPriceFlag = cli.StringFlag{ Name: "gpomin", Usage: "Minimum suggested gas price", Value: new(big.Int).Mul(big.NewInt(50), common.Shannon).String(), } GpoMaxGasPriceFlag = cli.StringFlag{ Name: "gpomax", Usage: "Maximum suggested gas price", Value: new(big.Int).Mul(big.NewInt(500), common.Shannon).String(), } GpoFullBlockRatioFlag = cli.IntFlag{ Name: "gpofull", Usage: "Full block threshold for gas price calculation (%)", Value: 80, } GpobaseStepDownFlag = cli.IntFlag{ Name: "gpobasedown", Usage: "Suggested gas price base step down ratio (1/1000)", Value: 10, } GpobaseStepUpFlag = cli.IntFlag{ Name: "gpobaseup", Usage: "Suggested gas price base step up ratio (1/1000)", Value: 100, } GpobaseCorrectionFactorFlag = cli.IntFlag{ Name: "gpobasecf", Usage: "Suggested gas price base correction factor (%)", Value: 110, } )
Functions ¶
func CheckLegalese ¶ added in v0.9.39
func CheckLegalese(datadir string)
func ExportAppendChain ¶
func ExportChain ¶
func ExportChain(chainmgr *core.ChainManager, fn string) error
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf formats a message to standard error and exits the program. The message is also printed to standard output if standard error is redirected to a different file.
func FormatTransactionData ¶ added in v0.9.39
func ImportChain ¶
func ImportChain(chain *core.ChainManager, fn string) error
func InitOlympic ¶ added in v1.0.1
func InitOlympic()
func IpcSocketPath ¶ added in v0.9.39
func MakeAccountManager ¶ added in v0.9.39
MakeChain creates an account manager from set command line flags.
func MakeEthConfig ¶ added in v0.9.39
MakeEthConfig creates ethereum options from set command line flags.
func MakeNodeKey ¶ added in v0.9.39
func MakeNodeKey(ctx *cli.Context) (key *ecdsa.PrivateKey)
MakeNodeKey creates a node key from set command line flags.
func ParamToAddress ¶ added in v0.9.39
func PromptConfirm ¶ added in v0.9.39
func PromptPassword ¶ added in v0.9.39
func SetupLogger ¶ added in v0.9.39
SetupLogger configures glog from the logging-related command line flags.
func StartEthereum ¶ added in v0.9.39
func StartPProf ¶ added in v0.9.39
Types ¶
type DirectoryFlag ¶
type DirectoryFlag struct { cli.GenericFlag Name string Value DirectoryString Usage string EnvVar string }
Custom cli.Flag type which expand the received string to an absolute path. e.g. ~/.ethereum -> /home/username/.ethereum
func (DirectoryFlag) Apply ¶
func (self DirectoryFlag) Apply(set *flag.FlagSet)
called by cli library, grabs variable from environment (if in env) and adds variable to flag set for parsing.
func (*DirectoryFlag) Set ¶
func (self *DirectoryFlag) Set(value string)
func (DirectoryFlag) String ¶
func (self DirectoryFlag) String() string
type DirectoryString ¶
type DirectoryString struct {
Value string
}
Custom type which is registered in the flags library which cli uses for argument parsing. This allows us to expand Value to an absolute path when the argument is parsed
func (*DirectoryString) Set ¶
func (self *DirectoryString) Set(value string) error
func (*DirectoryString) String ¶
func (self *DirectoryString) String() string