Documentation ¶
Overview ¶
Package utils contains internal helper functions for go-ethereum commands.
Package utils contains internal helper functions for go-ethereum commands.
Index ¶
- Variables
- func ChainDbName(ctx *cli.Context) string
- func ExportAppendChain(blockchain *core.BlockChain, fn string, first uint64, last uint64) error
- func ExportChain(blockchain *core.BlockChain, fn string) error
- func Fatalf(format string, args ...interface{})
- func FormatTransactionData(data string) []byte
- func ImportChain(chain *core.BlockChain, fn string) error
- func MakeAddress(accman *accounts.Manager, account string) (accounts.Account, error)
- func MakeBootstrapNodes(ctx *cli.Context) []*discover.Node
- func MakeBootstrapNodesV5(ctx *cli.Context) []*discv5.Node
- func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chainDb ethdb.Database)
- func MakeChainConfig(ctx *cli.Context, stack *node.Node) *params.ChainConfig
- func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *params.ChainConfig
- func MakeChainDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database
- func MakeConsolePreloads(ctx *cli.Context) []string
- func MakeDataDir(ctx *cli.Context) string
- func MakeDatabaseHandles() int
- func MakeDiscoveryV5Address(ctx *cli.Context) string
- func MakeEtherbase(accman *accounts.Manager, ctx *cli.Context) common.Address
- func MakeHTTPRpcHost(ctx *cli.Context) string
- func MakeIPCPath(ctx *cli.Context) string
- func MakeListenAddress(ctx *cli.Context) string
- func MakeMinerExtra(extra []byte, ctx *cli.Context) []byte
- func MakeNAT(ctx *cli.Context) nat.Interface
- func MakeNode(ctx *cli.Context, name, gitCommit string) *node.Node
- func MakeNodeKey(ctx *cli.Context) *ecdsa.PrivateKey
- func MakePasswordList(ctx *cli.Context) []string
- func MakeRPCModules(input string) []string
- func MakeWSRpcHost(ctx *cli.Context) string
- func NewApp(gitCommit, usage string) *cli.App
- func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte)
- func RegisterEthStatsService(stack *node.Node, url string)
- func RegisterShhService(stack *node.Node)
- func SetupNetwork(ctx *cli.Context)
- func StartNode(stack *node.Node)
- type DirectoryFlag
- type DirectoryString
Constants ¶
This section is empty.
Variables ¶
var ( // General settings DataDirFlag = DirectoryFlag{ Name: "datadir", Usage: "Data directory for the databases and keystore", Value: DirectoryString{node.DefaultDataDir()}, } KeyStoreDirFlag = DirectoryFlag{ Name: "keystore", Usage: "Directory for the keystore (default = inside the datadir)", } NetworkIdFlag = cli.IntFlag{ Name: "networkid", Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten)", Value: eth.NetworkId, } TestNetFlag = cli.BoolFlag{ Name: "testnet", Usage: "Ropsten network: pre-configured test network", } DevModeFlag = cli.BoolFlag{ Name: "dev", Usage: "Developer mode: pre-configured private network with several debugging flags", } IdentityFlag = cli.StringFlag{ Name: "identity", Usage: "Custom node name", } DocRootFlag = DirectoryFlag{ Name: "docroot", Usage: "Document Root for HTTPClient file scheme", Value: DirectoryString{homeDir()}, } FastSyncFlag = cli.BoolFlag{ Name: "fast", Usage: "Enable fast syncing through state downloads", } LightModeFlag = cli.BoolFlag{ Name: "light", Usage: "Enable light client mode", } LightServFlag = cli.IntFlag{ Name: "lightserv", Usage: "Maximum percentage of time allowed for serving LES requests (0-90)", Value: 0, } LightPeersFlag = cli.IntFlag{ Name: "lightpeers", Usage: "Maximum number of LES client peers", Value: 20, } LightKDFFlag = cli.BoolFlag{ Name: "lightkdf", Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength", } // Performance tuning settings CacheFlag = cli.IntFlag{ Name: "cache", Usage: "Megabytes of memory allocated to internal caching (min 16MB / database forced)", Value: 128, } TrieCacheGenFlag = cli.IntFlag{ Name: "trie-cache-gens", Usage: "Number of trie node generations to keep in memory", Value: int(state.MaxTrieCacheGen), } // Miner settings MiningEnabledFlag = cli.BoolFlag{ Name: "mine", Usage: "Enable mining", } MinerThreadsFlag = cli.IntFlag{ Name: "minerthreads", Usage: "Number of CPU threads to use for mining", Value: runtime.NumCPU(), } TargetGasLimitFlag = cli.StringFlag{ Name: "targetgaslimit", Usage: "Target gas limit sets the artificial target gas floor for the blocks to mine", Value: params.GenesisGasLimit.String(), } AutoDAGFlag = cli.BoolFlag{ Name: "autodag", Usage: "Enable automatic DAG pregeneration", } EtherbaseFlag = cli.StringFlag{ Name: "etherbase", Usage: "Public address for block mining rewards (default = first account created)", Value: "0", } GasPriceFlag = cli.StringFlag{ Name: "gasprice", Usage: "Minimal gas price to accept for mining a transactions", Value: new(big.Int).Mul(big.NewInt(20), common.Shannon).String(), } ExtraDataFlag = cli.StringFlag{ Name: "extradata", Usage: "Block extra data set by the miner (default = client version)", } // Account settings UnlockedAccountFlag = cli.StringFlag{ Name: "unlock", Usage: "Comma separated list of accounts to unlock", Value: "", } PasswordFileFlag = cli.StringFlag{ Name: "password", Usage: "Password file to use for non-inteactive password input", Value: "", } 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", } VMEnableDebugFlag = cli.BoolFlag{ Name: "vmdebug", Usage: "Record information useful for VM and contract debugging", } // Logging and debug settings EthStatsURLFlag = cli.StringFlag{ Name: "ethstats", Usage: "Reporting URL of a ethstats service (nodename:secret@host:port)", } MetricsEnabledFlag = cli.BoolFlag{ Name: metrics.MetricsEnabledFlag, Usage: "Enable metrics collection and reporting", } FakePoWFlag = cli.BoolFlag{ Name: "fakepow", Usage: "Disables proof-of-work verification", } // RPC settings RPCEnabledFlag = cli.BoolFlag{ Name: "rpc", Usage: "Enable the HTTP-RPC server", } RPCListenAddrFlag = cli.StringFlag{ Name: "rpcaddr", Usage: "HTTP-RPC server listening interface", Value: node.DefaultHTTPHost, } RPCPortFlag = cli.IntFlag{ Name: "rpcport", Usage: "HTTP-RPC server listening port", Value: node.DefaultHTTPPort, } RPCCORSDomainFlag = cli.StringFlag{ Name: "rpccorsdomain", Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)", Value: "", } RPCApiFlag = cli.StringFlag{ Name: "rpcapi", Usage: "API's offered over the HTTP-RPC interface", Value: rpc.DefaultHTTPApis, } IPCDisabledFlag = cli.BoolFlag{ Name: "ipcdisable", Usage: "Disable the IPC-RPC server", } IPCApiFlag = cli.StringFlag{ Name: "ipcapi", Usage: "APIs offered over the IPC-RPC interface", Value: rpc.DefaultIPCApis, } IPCPathFlag = DirectoryFlag{ Name: "ipcpath", Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)", Value: DirectoryString{"geth.ipc"}, } WSEnabledFlag = cli.BoolFlag{ Name: "ws", Usage: "Enable the WS-RPC server", } WSListenAddrFlag = cli.StringFlag{ Name: "wsaddr", Usage: "WS-RPC server listening interface", Value: node.DefaultWSHost, } WSPortFlag = cli.IntFlag{ Name: "wsport", Usage: "WS-RPC server listening port", Value: node.DefaultWSPort, } WSApiFlag = cli.StringFlag{ Name: "wsapi", Usage: "API's offered over the WS-RPC interface", Value: rpc.DefaultHTTPApis, } WSAllowedOriginsFlag = cli.StringFlag{ Name: "wsorigins", Usage: "Origins from which to accept websockets requests", Value: "", } ExecFlag = cli.StringFlag{ Name: "exec", Usage: "Execute JavaScript statement (only in combination with console/attach)", } PreloadJSFlag = cli.StringFlag{ Name: "preload", Usage: "Comma separated list of JavaScript files to preload into the console", } // 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: "Comma 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)", } DiscoveryV5Flag = cli.BoolFlag{ Name: "v5disc", Usage: "Enables the experimental RLPx V5 (Topic Discovery) mechanism", } NetrestrictFlag = cli.StringFlag{ Name: "netrestrict", Usage: "Restricts network communication to the given IP networks (CIDR masks)", } 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: "JavaScript root path for `loadScript`", Value: ".", } SolcPathFlag = cli.StringFlag{ Name: "solc", Usage: "Solidity compiler command to be used", Value: "solc", } // Gas price oracle settings GpoMinGasPriceFlag = cli.StringFlag{ Name: "gpomin", Usage: "Minimum suggested gas price", Value: new(big.Int).Mul(big.NewInt(20), 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 ChainDbName ¶ added in v1.5.1
func ChainDbName(ctx *cli.Context) string
func ExportAppendChain ¶ added in v1.0.2
func ExportChain ¶ added in v1.0.2
func ExportChain(blockchain *core.BlockChain, fn string) error
func Fatalf ¶ added in v1.0.2
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 ¶
func ImportChain ¶ added in v1.0.2
func ImportChain(chain *core.BlockChain, fn string) error
func MakeAddress ¶ added in v1.4.5
MakeAddress converts an account specified directly as a hex encoded string or a key index in the key store to an internal account representation.
func MakeBootstrapNodes ¶ added in v1.4.5
MakeBootstrapNodes creates a list of bootstrap nodes from the command line flags, reverting to pre-configured ones if none have been specified.
func MakeBootstrapNodesV5 ¶ added in v1.5.1
MakeBootstrapNodesV5 creates a list of bootstrap nodes from the command line flags, reverting to pre-configured ones if none have been specified.
func MakeChainConfig ¶ added in v1.5.1
func MakeChainConfig(ctx *cli.Context, stack *node.Node) *params.ChainConfig
MakeChainConfig reads the chain configuration from the database in ctx.Datadir.
func MakeChainConfigFromDb ¶ added in v1.5.1
func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *params.ChainConfig
MakeChainConfigFromDb reads the chain configuration from the given database.
func MakeChainDatabase ¶ added in v1.4.5
MakeChainDatabase open an LevelDB using the flags passed to the client and will hard crash if it fails.
func MakeConsolePreloads ¶ added in v1.5.1
func MakeConsolePreloads(ctx *cli.Context) []string
MakeConsolePreloads retrieves the absolute paths for the console JavaScript scripts to preload before starting.
func MakeDataDir ¶ added in v1.5.1
func MakeDataDir(ctx *cli.Context) string
MakeDataDir retrieves the currently requested data directory, terminating if none (or the empty string) is specified. If the node is starting a testnet, the a subdirectory of the specified datadir will be used.
func MakeDatabaseHandles ¶ added in v1.4.5
func MakeDatabaseHandles() int
MakeDatabaseHandles raises out the number of allowed file handles per process for Geth and returns half of the allowance to assign to the database.
func MakeDiscoveryV5Address ¶ added in v1.5.1
func MakeDiscoveryV5Address(ctx *cli.Context) string
MakeDiscoveryV5Address creates a UDP listening address string from set command line flags for the V5 discovery protocol.
func MakeEtherbase ¶ added in v1.4.5
MakeEtherbase retrieves the etherbase either from the directly specified command line flags or from the keystore if CLI indexed.
func MakeHTTPRpcHost ¶ added in v1.4.5
func MakeHTTPRpcHost(ctx *cli.Context) string
MakeHTTPRpcHost creates the HTTP RPC listener interface string from the set command line flags, returning empty if the HTTP endpoint is disabled.
func MakeIPCPath ¶ added in v1.4.5
func MakeIPCPath(ctx *cli.Context) string
MakeIPCPath creates an IPC path configuration from the set command line flags, returning an empty string if IPC was explicitly disabled, or the set path.
func MakeListenAddress ¶ added in v1.4.5
func MakeListenAddress(ctx *cli.Context) string
MakeListenAddress creates a TCP listening address string from set command line flags.
func MakeMinerExtra ¶ added in v1.4.5
MakeMinerExtra resolves extradata for the miner from the set command line flags or returns a default one composed on the client, runtime and OS metadata.
func MakeNode ¶ added in v1.5.1
MakeNode configures a node with no services from command line flags.
func MakeNodeKey ¶ added in v1.0.2
func MakeNodeKey(ctx *cli.Context) *ecdsa.PrivateKey
MakeNodeKey creates a node key from set command line flags, either loading it from a file or as a specified hex value. If neither flags were provided, this method returns nil and an emphemeral key is to be generated.
func MakePasswordList ¶ added in v1.4.5
func MakePasswordList(ctx *cli.Context) []string
MakePasswordList reads password lines from the file specified by --password.
func MakeRPCModules ¶ added in v1.4.5
MakeRPCModules splits input separated by a comma and trims excessive white space from the substrings.
func MakeWSRpcHost ¶ added in v1.4.5
func MakeWSRpcHost(ctx *cli.Context) string
MakeWSRpcHost creates the WebSocket RPC listener interface string from the set command line flags, returning empty if the HTTP endpoint is disabled.
func NewApp ¶ added in v1.0.2
func NewApp(gitCommit, usage string) *cli.App
NewApp creates an app with sane defaults.
func RegisterEthService ¶ added in v1.5.1
RegisterEthService configures eth.Ethereum from command line flags and adds it to the given node.
func RegisterEthStatsService ¶ added in v1.5.8
RegisterEthStatsService configures the Ethereum Stats daemon and adds it to th egiven node.
func RegisterShhService ¶ added in v1.5.1
RegisterShhService configures Whisper and adds it to the given node.
func SetupNetwork ¶ added in v1.4.5
func SetupNetwork(ctx *cli.Context)
SetupNetwork configures the system for either the main net or some test network.
Types ¶
type DirectoryFlag ¶ added in v1.0.2
type DirectoryFlag struct { 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 ¶ added in v1.0.2
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) GetName ¶ added in v1.5.8
func (self DirectoryFlag) GetName() string
func (*DirectoryFlag) Set ¶ added in v1.0.2
func (self *DirectoryFlag) Set(value string)
func (DirectoryFlag) String ¶ added in v1.0.2
func (self DirectoryFlag) String() string
type DirectoryString ¶ added in v1.0.2
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 ¶ added in v1.0.2
func (self *DirectoryString) Set(value string) error
func (*DirectoryString) String ¶ added in v1.0.2
func (self *DirectoryString) String() string