utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2019 License: LGPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Modified from go-ethereum under GNU Lesser General Public License

Modified from go-ethereum under GNU Lesser General Public License

Modified from go-ethereum under GNU Lesser General Public License

Index

Constants

This section is empty.

Variables

View Source
var (
	// General settings
	DataDirFlag = DirectoryFlag{
		Name:  "datadir",
		Usage: "Data directory for the databases and keystore",
		Value: DirectoryString{service.DefaultDataDir()},
	}
	LogLevelFlag = cli.StringFlag{
		Name:  "log_level",
		Usage: "log level",
	}
	CleanFlag = cli.BoolFlag{
		Name:  "clean",
		Usage: "clean database ?",
	}
	StartSimulatedMiningFlag = cli.BoolFlag{
		Name:  "start_simulated_mining",
		Usage: "start simulated mining ?",
	}
	GenesisDirFlag = cli.StringFlag{
		Name:  "genesis_dir",
		Usage: "gensis data dir",
	}
	NumChainsFlag = cli.IntFlag{
		Name:  "num_chains",
		Usage: "chain number",
	}
	NumShardsFlag = cli.IntFlag{
		Name:  "num_shards",
		Usage: "shard number",
	}
	RootBlockIntervalSecFlag = cli.IntFlag{
		Name:  "root_block_interval_sec",
		Usage: "interval time of root block",
	}
	MinorBlockIntervalSecFlag = cli.IntFlag{
		Name:  "minor_block_interval_sec",
		Usage: "",
	}
	NetworkIdFlag = cli.IntFlag{
		Name:  "network_id",
		Usage: "net work id",
	}
	NumSlavesFlag = cli.IntFlag{
		Name:  "num_slaves",
		Usage: "slaves number",
	}
	PortStartFlag = cli.IntFlag{
		Name:  "port_start",
		Usage: "slave start port",
	}
	DbPathRootFlag = cli.StringFlag{
		Name:  "db_path_root",
		Usage: "Data directory for the databases and keystore",
	}
	P2pFlag = cli.BoolFlag{
		Name:  "p2p",
		Usage: "enables new p2p module",
	}
	EnableTransactionHistoryFlag = cli.BoolFlag{
		Name:  "enable_transaction_history",
		Usage: "enable transaction history function",
	}
	SimpleNetworkBootstrapHostFlag = cli.StringFlag{
		Name:  "simple_network_bootstrap_host",
		Usage: "simple network bootstrap host",
		Value: "127.0.0.1",
	}
	SimpleNetworkBootstrapPortFlag = cli.Uint64Flag{
		Name:  "simple_network_bootstrap_port",
		Usage: "simple network bootstrap port",
		Value: 38291,
	}
	MaxPeersFlag = cli.Uint64Flag{
		Name:  "max_peers",
		Usage: "max peer for new p2p module",
	}
	BootnodesFlag = cli.StringFlag{
		Name:  "bootnodes",
		Usage: "comma separated encodes in the format: enode://PUBKEY@IP:PORT",
	}
	UpnpFlag = cli.BoolFlag{
		Name:  "upnp",
		Usage: "if true,automatically runs a upnp service that sets port mapping on upnp-enabled devices",
	}
	PrivkeyFlag = cli.StringFlag{
		Name:  "privkey",
		Usage: "if empty,will be automatically generated; but note that it will be lost upon node reboot",
	}
	ServiceFlag = cli.StringFlag{
		Name:  "service",
		Usage: "svrvice type,if has eight slaves,fill like(S0,S2,...S7)",
		Value: "master",
	}

	// Performance tuning settings
	CacheFlag = cli.IntFlag{
		Name:  "cache",
		Usage: "Megabytes of memory allocated to internal caching",
		Value: 1024,
	}
	// RPC settings
	RPCDisabledFlag = cli.BoolFlag{
		Name:  "json_rpc_disable",
		Usage: "disable the public HTTP-RPC server",
	}
	RPCListenAddrFlag = cli.StringFlag{
		Name:  "json_rpc_addr",
		Usage: "HTTP-RPC server listening interface",
		Value: "0.0.0.0",
	}
	RPCPortFlag = cli.IntFlag{
		Name:  "json_rpc_port",
		Usage: "public HTTP-RPC server listening port",
	}
	PrivateRPCListenAddrFlag = cli.StringFlag{
		Name:  "json_rpc_private_addr",
		Usage: "HTTP-RPC server listening interface",
		Value: service.DefaultHTTPHost,
	}
	PrivateRPCPortFlag = cli.IntFlag{
		Name:  "json_rpc_private_port",
		Usage: "public HTTP-RPC server listening port",
	}

	GRPCAddrFlag = cli.StringFlag{
		Name:  "grpc_addr",
		Usage: "master or slave grpc address",
		Value: config.GrpcHost,
	}
	GRPCPortFlag = cli.IntFlag{
		Name:  "grpc_port",
		Usage: "public json rpc port",
		Value: int(config.GrpcPort),
	}
	P2pPortFlag = cli.IntFlag{
		Name:  "p2p_port",
		Usage: "Network listening port",
	}

	IPCEnableFlag = cli.BoolFlag{
		Name:  "ipc",
		Usage: "enable the IPC-RPC server",
	}
	IPCPathFlag = DirectoryFlag{
		Name:  "ipcpath",
		Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)",
	}
	MaxPendingPeersFlag = cli.IntFlag{
		Name:  "maxpendpeers",
		Usage: "Maximum number of pending connection attempts (defaults used if set to 0)",
		Value: 0,
	}
	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",
	}
)
View Source
var (
	CommandHelpTemplate = `` /* 471-byte string literal not displayed */

)

Functions

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 MakeDataDir

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 MigrateFlags

func MigrateFlags(action func(ctx *cli.Context) error) func(*cli.Context) error

MigrateFlags sets the global flag from a local flag when it's set. This is a temporary function used for migrating old command/flags to the new format.

e.g. geth account new --keystore /tmp/mykeystore --lightkdf

is equivalent after calling this method with:

geth --keystore /tmp/mykeystore --lightkdf account new

This allows the use of the existing configuration functionality. When all flags are migrated this function can be removed and the existing configuration functionality must be changed that is uses local flags

func NewApp

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

NewApp creates an app with sane defaults.

func RegisterMasterService

func RegisterMasterService(stack *service.Node, cfg *config.ClusterConfig)

RegisterEthService adds an QuarkChain client to the stack.

func RegisterSlaveService

func RegisterSlaveService(stack *service.Node, clusterCfg *config.ClusterConfig, cfg *config.SlaveConfig)

func SetClusterConfig

func SetClusterConfig(ctx *cli.Context, cfg *config.ClusterConfig)

func SetNodeConfig

func SetNodeConfig(ctx *cli.Context, cfg *service.Config, clstrCfg *config.ClusterConfig)

SetNodeConfig applies node-related command line flags to the config.

func SetP2PConfig

func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config, clstrCfg *config.ClusterConfig)

func StartService

func StartService(stack *service.Node)

Types

type BigFlag

type BigFlag struct {
	Name  string
	Value *big.Int
	Usage string
}

BigFlag is a command line flag that accepts 256 bit big integers in decimal or hexadecimal syntax.

func (BigFlag) Apply

func (f BigFlag) Apply(set *flag.FlagSet)

func (BigFlag) GetName

func (f BigFlag) GetName() string

func (BigFlag) String

func (f BigFlag) String() string

type DirectoryFlag

type DirectoryFlag struct {
	Name  string
	Value DirectoryString
	Usage string
}

Custom cli.Flag type which expand the received string to an absolute path. e.g. ~/.QuarkChain -> /home/username/.QuarkChain

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) GetName

func (self DirectoryFlag) GetName() string

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

type TextMarshaler

type TextMarshaler interface {
	encoding.TextMarshaler
	encoding.TextUnmarshaler
}

type TextMarshalerFlag

type TextMarshalerFlag struct {
	Name  string
	Value TextMarshaler
	Usage string
}

TextMarshalerFlag wraps a TextMarshaler value.

func (TextMarshalerFlag) Apply

func (f TextMarshalerFlag) Apply(set *flag.FlagSet)

func (TextMarshalerFlag) GetName

func (f TextMarshalerFlag) GetName() string

func (TextMarshalerFlag) String

func (f TextMarshalerFlag) String() string

Jump to

Keyboard shortcuts

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