utils

package
v0.9.32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2015 License: LGPL-2.1-or-later, GPL-2.0 Imports: 34 Imported by: 0

Documentation

Overview

This file is part of go-ethereum

go-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

go-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with go-ethereum.  If not, see <http://www.gnu.org/licenses/>.

*

  • @authors
  • Jeffrey Wilcke <i@jev.io>
  • Viktor Tron <viktor@ethdev.com>

Index

Constants

This section is empty.

Variables

View Source
var (
	// General settings
	DataDirFlag = DirectoryFlag{
		Name:  "datadir",
		Usage: "Data directory to be used",
		Value: DirectoryString{common.DefaultDataDir()},
	}
	ProtocolVersionFlag = cli.IntFlag{
		Name:  "protocolversion",
		Usage: "ETH protocol version (integer)",
		Value: eth.ProtocolVersion,
	}
	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,
	}
	IdentityFlag = cli.StringFlag{
		Name:  "identity",
		Usage: "Custom node name",
	}
	NatspecEnabledFlag = cli.BoolFlag{
		Name:  "natspec",
		Usage: "Enable NatSpec confirmation notice",
	}

	// 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 of your primary account is used",
		Value: "primary",
	}
	GasPriceFlag = cli.StringFlag{
		Name:  "gasprice",
		Usage: "Sets the minimal gasprice when mining transactions",
		Value: new(big.Int).Mul(big.NewInt(1), common.Szabo).String(),
	}

	UnlockedAccountFlag = cli.StringFlag{
		Name:  "unlock",
		Usage: "Unlock the account given until this program exits (prompts for password). '--unlock primary' unlocks the primary account",
		Value: "",
	}
	PasswordFileFlag = cli.StringFlag{
		Name:  "password",
		Usage: "Path to password file to use with options and subcommands needing a password",
		Value: "",
	}

	// 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(),
	}
	VMDebugFlag = cli.BoolFlag{
		Name:  "vmdebug",
		Usage: "Virtual Machine debug output",
	}
	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,
	}

	// 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(1), common.Szabo).String(),
	}
	GpoMaxGasPriceFlag = cli.StringFlag{
		Name:  "gpomax",
		Usage: "Maximum suggested gas price",
		Value: new(big.Int).Mul(big.NewInt(100), common.Szabo).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 ExportAppendChain added in v0.9.28

func ExportAppendChain(chainmgr *core.ChainManager, fn string, first uint64, last uint64) error

func ExportChain added in v0.9.17

func ExportChain(chainmgr *core.ChainManager, fn string) error

func Fatalf added in v0.9.17

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 FormatTransactionData(data string) []byte

func HandleInterrupt

func HandleInterrupt()

go routine that call interrupt handlers in order of registering

func ImportChain added in v0.8.4

func ImportChain(chain *core.ChainManager, fn string) error

func IpcSocketPath added in v0.9.32

func IpcSocketPath(ctx *cli.Context) (ipcpath string)

func MakeAccountManager added in v0.9.26

func MakeAccountManager(ctx *cli.Context) *accounts.Manager

MakeChain creates an account manager from set command line flags.

func MakeChain added in v0.9.26

func MakeChain(ctx *cli.Context) (chain *core.ChainManager, blockDB, stateDB, extraDB common.Database)

MakeChain creates a chain manager from set command line flags.

func MakeEthConfig added in v0.9.17

func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config

MakeEthConfig creates ethereum options from set command line flags.

func MakeNAT added in v0.9.26

func MakeNAT(ctx *cli.Context) nat.Interface

MakeNAT creates a port mapper from set command line flags.

func MakeNodeKey added in v0.9.26

func MakeNodeKey(ctx *cli.Context) (key *ecdsa.PrivateKey)

MakeNodeKey creates a node key from set command line flags.

func NewApp added in v0.9.17

func NewApp(version, usage string) *cli.App

NewApp creates an app with sane defaults.

func PromptConfirm added in v0.9.23

func PromptConfirm(prompt string) (bool, error)

func PromptPassword added in v0.9.23

func PromptPassword(prompt string, warnTerm bool) (string, error)

func RegisterInterrupt

func RegisterInterrupt(cb func(os.Signal))

Register interrupt handlers callbacks

func RunInterruptCallbacks

func RunInterruptCallbacks(sig os.Signal)

func SetupLogger added in v0.9.26

func SetupLogger(ctx *cli.Context)

SetupLogger configures glog from the logging-related command line flags.

func StartEthereum

func StartEthereum(ethereum *eth.Ethereum)

func StartEthereumForTest added in v0.9.17

func StartEthereumForTest(ethereum *eth.Ethereum)

func StartIPC added in v0.9.32

func StartIPC(eth *eth.Ethereum, ctx *cli.Context) error

func StartPProf added in v0.9.17

func StartPProf(ctx *cli.Context)

func StartRPC added in v0.9.17

func StartRPC(eth *eth.Ethereum, ctx *cli.Context) error

Types

type DirectoryFlag added in v0.9.17

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 added in v0.9.17

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 added in v0.9.17

func (self *DirectoryFlag) Set(value string)

func (DirectoryFlag) String added in v0.9.17

func (self DirectoryFlag) String() string

type DirectoryString added in v0.9.17

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 v0.9.17

func (self *DirectoryString) Set(value string) error

func (*DirectoryString) String added in v0.9.17

func (self *DirectoryString) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL