utils

package
v1.6.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: GPL-3.0 Imports: 57 Imported by: 53

Documentation

Overview

Package utils contains internal helper functions for klaytn commands.

utils package provides various helper functions especially for handling various commands and options.

Source Files

Each file contains the following contents

  • app.go : Provides NewCLI() function but it is not being used.
  • cmd.go : Provide import/export chain functions but it is not being used.
  • customflags.go : Provides `DirectoryString`, `DirectoryFlags` and marshaling functions to support custom flags
  • files.go : Provides `WriteFile` function to store contents in a given file
  • flags.go : Defines various flags which can be used in running a node
  • flaggroup.go : Categorizes flags into groups to print structured help descriptions.
  • helptemplate.go : Provides a template for help contents which explains option names and its usages
  • strings.go : Provides helper functions to handle string manipulations
  • testcmd.go : Provides test functions to test command arguments
  • usage.go : Provides help printer which prints help contents neatly

Index

Constants

This section is empty.

Variables

View Source
var (
	// General settings
	NetworkTypeFlag = cli.StringFlag{
		Name:  "networktype",
		Usage: "Klaytn network type (main-net (mn), service chain-net (scn))",
		Value: "mn",
	}
	DbTypeFlag = cli.StringFlag{
		Name:  "dbtype",
		Usage: `Blockchain storage database type ("LevelDB", "BadgerDB", "MemoryDB", "DynamoDBS3")`,
		Value: "LevelDB",
	}
	SrvTypeFlag = cli.StringFlag{
		Name:  "srvtype",
		Usage: `json rpc server type ("http", "fasthttp")`,
		Value: "fasthttp",
	}
	DataDirFlag = DirectoryFlag{
		Name:  "datadir",
		Usage: "Data directory for the databases and keystore. This value is only used in local DB.",
		Value: DirectoryString{node.DefaultDataDir()},
	}
	KeyStoreDirFlag = DirectoryFlag{
		Name:  "keystore",
		Usage: "Directory for the keystore (default = inside the datadir)",
	}
	// TODO-Klaytn-Bootnode: redefine networkid
	NetworkIdFlag = cli.Uint64Flag{
		Name:  "networkid",
		Usage: "Network identifier (integer, 1=MainNet (Not yet launched), 1000=Aspen, 1001=Baobab)",
		Value: cn.GetDefaultConfig().NetworkId,
	}
	IdentityFlag = cli.StringFlag{
		Name:  "identity",
		Usage: "Custom node name",
	}
	DocRootFlag = DirectoryFlag{
		Name:  "docroot",
		Usage: "Document Root for HTTPClient file scheme",
		Value: DirectoryString{homeDir()},
	}

	SyncModeFlag = TextMarshalerFlag{
		Name:  "syncmode",
		Usage: `Blockchain sync mode (only "full" is supported)`,
		Value: &defaultSyncMode,
	}
	GCModeFlag = cli.StringFlag{
		Name:  "gcmode",
		Usage: `Blockchain garbage collection mode ("full", "archive")`,
		Value: "full",
	}
	LightKDFFlag = cli.BoolFlag{
		Name:  "lightkdf",
		Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength",
	}
	OverwriteGenesisFlag = cli.BoolFlag{
		Name:  "overwrite-genesis",
		Usage: "Overwrites genesis block with the given new genesis block for testing purpose",
	}
	StartBlockNumberFlag = cli.Uint64Flag{
		Name:  "start-block-num",
		Usage: "Starts the node from the given block number. Starting from 0 is not supported.",
	}
	// Transaction pool settings
	TxPoolNoLocalsFlag = cli.BoolFlag{
		Name:  "txpool.nolocals",
		Usage: "Disables price exemptions for locally submitted transactions",
	}
	TxPoolAllowLocalAnchorTxFlag = cli.BoolFlag{
		Name:  "txpool.allow-local-anchortx",
		Usage: "Allow locally submitted anchoring transactions",
	}
	TxPoolJournalFlag = cli.StringFlag{
		Name:  "txpool.journal",
		Usage: "Disk journal for local transaction to survive node restarts",
		Value: blockchain.DefaultTxPoolConfig.Journal,
	}
	TxPoolJournalIntervalFlag = cli.DurationFlag{
		Name:  "txpool.journal-interval",
		Usage: "Time interval to regenerate the local transaction journal",
		Value: blockchain.DefaultTxPoolConfig.JournalInterval,
	}
	TxPoolPriceLimitFlag = cli.Uint64Flag{
		Name:  "txpool.pricelimit",
		Usage: "Minimum gas price limit to enforce for acceptance into the pool",
		Value: cn.GetDefaultConfig().TxPool.PriceLimit,
	}
	TxPoolPriceBumpFlag = cli.Uint64Flag{
		Name:  "txpool.pricebump",
		Usage: "Price bump percentage to replace an already existing transaction",
		Value: cn.GetDefaultConfig().TxPool.PriceBump,
	}
	TxPoolExecSlotsAccountFlag = cli.Uint64Flag{
		Name:  "txpool.exec-slots.account",
		Usage: "Number of executable transaction slots guaranteed per account",
		Value: cn.GetDefaultConfig().TxPool.ExecSlotsAccount,
	}
	TxPoolExecSlotsAllFlag = cli.Uint64Flag{
		Name:  "txpool.exec-slots.all",
		Usage: "Maximum number of executable transaction slots for all accounts",
		Value: cn.GetDefaultConfig().TxPool.ExecSlotsAll,
	}
	TxPoolNonExecSlotsAccountFlag = cli.Uint64Flag{
		Name:  "txpool.nonexec-slots.account",
		Usage: "Maximum number of non-executable transaction slots permitted per account",
		Value: cn.GetDefaultConfig().TxPool.NonExecSlotsAccount,
	}
	TxPoolNonExecSlotsAllFlag = cli.Uint64Flag{
		Name:  "txpool.nonexec-slots.all",
		Usage: "Maximum number of non-executable transaction slots for all accounts",
		Value: cn.GetDefaultConfig().TxPool.NonExecSlotsAll,
	}
	TxPoolKeepLocalsFlag = cli.BoolFlag{
		Name:  "txpool.keeplocals",
		Usage: "Disables removing timed-out local transactions",
	}
	TxPoolLifetimeFlag = cli.DurationFlag{
		Name:  "txpool.lifetime",
		Usage: "Maximum amount of time non-executable transaction are queued",
		Value: cn.GetDefaultConfig().TxPool.Lifetime,
	}
	// KES
	KESNodeTypeServiceFlag = cli.BoolFlag{
		Name:  "kes.nodetype.service",
		Usage: "Run as a KES Service Node (Disable fetcher, downloader, and worker)",
	}
	SingleDBFlag = cli.BoolFlag{
		Name:  "db.single",
		Usage: "Create a single persistent storage. MiscDB, headerDB and etc are stored in one DB.",
	}
	NumStateTrieShardsFlag = cli.UintFlag{
		Name:  "db.num-statetrie-shards",
		Usage: "Number of internal shards of state trie DB shards. Should be power of 2",
		Value: 4,
	}
	LevelDBCacheSizeFlag = cli.IntFlag{
		Name:  "db.leveldb.cache-size",
		Usage: "Size of in-memory cache in LevelDB (MiB)",
		Value: 768,
	}
	// TODO-Klaytn-Database LevelDBCompressionTypeFlag should be removed before main-net release.
	LevelDBCompressionTypeFlag = cli.IntFlag{
		Name:  "db.leveldb.compression",
		Usage: "Determines the compression method for LevelDB. 0=AllNoCompression, 1=ReceiptOnlySnappyCompression, 2=StateTrieOnlyNoCompression, 3=AllSnappyCompression",
		Value: 0,
	}
	LevelDBNoBufferPoolFlag = cli.BoolFlag{
		Name:  "db.leveldb.no-buffer-pool",
		Usage: "Disables using buffer pool for LevelDB's block allocation",
	}
	DynamoDBTableNameFlag = cli.StringFlag{
		Name:  "db.dynamo.tablename",
		Usage: "Specifies DynamoDB table name. This is mandatory to use dynamoDB. (Set dbtype to use DynamoDBS3)",
	}
	DynamoDBRegionFlag = cli.StringFlag{
		Name:  "db.dynamo.region",
		Usage: "AWS region where the DynamoDB will be created.",
		Value: database.GetDefaultDynamoDBConfig().Region,
	}
	DynamoDBIsProvisionedFlag = cli.BoolFlag{
		Name:  "db.dynamo.is-provisioned",
		Usage: "Set DynamoDB billing mode to provision. The default billing mode is on-demand.",
	}
	DynamoDBReadCapacityFlag = cli.Int64Flag{
		Name:  "db.dynamo.read-capacity",
		Usage: "Read capacity unit of dynamoDB. If is-provisioned is not set, this flag will not be applied.",
		Value: database.GetDefaultDynamoDBConfig().ReadCapacityUnits,
	}
	DynamoDBWriteCapacityFlag = cli.Int64Flag{
		Name:  "db.dynamo.write-capacity",
		Usage: "Write capacity unit of dynamoDB. If is-provisioned is not set, this flag will not be applied",
		Value: database.GetDefaultDynamoDBConfig().WriteCapacityUnits,
	}
	DynamoDBReadOnlyFlag = cli.BoolFlag{
		Name:  "db.dynamo.read-only",
		Usage: "Disables write to DynamoDB. Only read is possible.",
	}
	NoParallelDBWriteFlag = cli.BoolFlag{
		Name:  "db.no-parallel-write",
		Usage: "Disables parallel writes of block data to persistent database",
	}
	DBNoPerformanceMetricsFlag = cli.BoolFlag{
		Name:  "db.no-perf-metrics",
		Usage: "Disables performance metrics of database's read and write operations",
	}
	TrieMemoryCacheSizeFlag = cli.IntFlag{
		Name:  "state.cache-size",
		Usage: "Size of in-memory cache of the global state (in MiB) to flush matured singleton trie nodes to disk",
		Value: 512,
	}
	TrieBlockIntervalFlag = cli.UintFlag{
		Name:  "state.block-interval",
		Usage: "An interval in terms of block number to commit the global state to disk",
		Value: blockchain.DefaultBlockInterval,
	}
	TriesInMemoryFlag = cli.Uint64Flag{
		Name:  "state.tries-in-memory",
		Usage: "The number of recent state tries residing in the memory",
		Value: blockchain.DefaultTriesInMemory,
	}
	CacheTypeFlag = cli.IntFlag{
		Name:  "cache.type",
		Usage: "Cache Type: 0=LRUCache, 1=LRUShardCache, 2=FIFOCache",
		Value: int(common.DefaultCacheType),
	}
	CacheScaleFlag = cli.IntFlag{
		Name:  "cache.scale",
		Usage: "Scale of cache (cache size = preset size * scale of cache(%))",
	}
	CacheUsageLevelFlag = cli.StringFlag{
		Name:  "cache.level",
		Usage: "Set the cache usage level ('saving', 'normal', 'extreme')",
	}
	MemorySizeFlag = cli.IntFlag{
		Name:  "cache.memory",
		Usage: "Set the physical RAM size (GB, Default: 16GB)",
	}
	TrieNodeCacheTypeFlag = cli.StringFlag{
		Name: "statedb.cache.type",
		Usage: "Set trie node cache type ('LocalCache', 'RemoteCache', " +
			"'HybridCache') (default = 'LocalCache')",
		Value: string(statedb.CacheTypeLocal),
	}
	NumFetcherPrefetchWorkerFlag = cli.IntFlag{
		Name:  "statedb.cache.num-fetcher-prefetch-worker",
		Usage: "Number of workers used to prefetch block when fetcher fetches block",
		Value: 32,
	}
	TrieNodeCacheRedisEndpointsFlag = cli.StringSliceFlag{
		Name:  "statedb.cache.redis.endpoints",
		Usage: "Set endpoints of redis trie node cache. More than one endpoints can be set",
	}
	TrieNodeCacheRedisClusterFlag = cli.BoolFlag{
		Name:  "statedb.cache.redis.cluster",
		Usage: "Enables cluster-enabled mode of redis trie node cache",
	}
	TrieNodeCacheRedisPublishBlockFlag = cli.BoolFlag{
		Name:  "statedb.cache.redis.publish",
		Usage: "Publishes every committed block to redis trie node cache",
	}
	TrieNodeCacheRedisSubscribeBlockFlag = cli.BoolFlag{
		Name:  "statedb.cache.redis.subscribe",
		Usage: "Subscribes blocks from redis trie node cache",
	}
	TrieNodeCacheLimitFlag = cli.IntFlag{
		Name:  "state.trie-cache-limit",
		Usage: "Memory allowance (MiB) to use for caching trie nodes in memory. -1 is for auto-scaling",
		Value: -1,
	}
	TrieNodeCacheSavePeriodFlag = cli.DurationFlag{
		Name:  "state.trie-cache-save-period",
		Usage: "Period of saving in memory trie cache to file if fastcache is used, 0 means disabled",
		Value: 0,
	}
	SenderTxHashIndexingFlag = cli.BoolFlag{
		Name:  "sendertxhashindexing",
		Usage: "Enables storing mapping information of senderTxHash to txHash",
	}
	ChildChainIndexingFlag = cli.BoolFlag{
		Name:  "childchainindexing",
		Usage: "Enables storing transaction hash of child chain transaction for fast access to child chain data",
	}
	TargetGasLimitFlag = cli.Uint64Flag{
		Name:  "targetgaslimit",
		Usage: "Target gas limit sets the artificial target gas floor for the blocks to mine",
		Value: params.GenesisGasLimit,
	}
	ServiceChainSignerFlag = cli.StringFlag{
		Name:  "scsigner",
		Usage: "Public address for signing blocks in the service chain (default = first account created)",
		Value: "0",
	}
	RewardbaseFlag = cli.StringFlag{
		Name:  "rewardbase",
		Usage: "Public address for block consensus rewards (default = first account created)",
		Value: "0",
	}
	ExtraDataFlag = cli.StringFlag{
		Name:  "extradata",
		Usage: "Block extra data set by the work (default = client version)",
	}

	TxResendIntervalFlag = cli.Uint64Flag{
		Name:  "txresend.interval",
		Usage: "Set the transaction resend interval in seconds",
		Value: uint64(cn.DefaultTxResendInterval),
	}
	TxResendCountFlag = cli.IntFlag{
		Name:  "txresend.max-count",
		Usage: "Set the max count of resending transactions",
		Value: cn.DefaultMaxResendTxCount,
	}
	//TODO-Klaytn-RemoveLater Remove this flag when we are confident with the new transaction resend logic
	TxResendUseLegacyFlag = cli.BoolFlag{
		Name:  "txresend.use-legacy",
		Usage: "Enable the legacy transaction resend logic (For testing only)",
	}
	// 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-interactive password input",
		Value: "",
	}

	VMEnableDebugFlag = cli.BoolFlag{
		Name:  "vmdebug",
		Usage: "Record information useful for VM and contract debugging",
	}
	VMLogTargetFlag = cli.IntFlag{
		Name:  "vmlog",
		Usage: "Set the output target of vmlog precompiled contract (0: no output, 1: file, 2: stdout, 3: both)",
		Value: 0,
	}
	VMTraceInternalTxFlag = cli.BoolFlag{
		Name:  "vm.internaltx",
		Usage: "Collect internal transaction data while processing a block",
	}

	// Logging and debug settings
	MetricsEnabledFlag = cli.BoolFlag{
		Name:  metricutils.MetricsEnabledFlag,
		Usage: "Enable metrics collection and reporting",
	}
	PrometheusExporterFlag = cli.BoolFlag{
		Name:  metricutils.PrometheusExporterFlag,
		Usage: "Enable prometheus exporter",
	}
	PrometheusExporterPortFlag = cli.IntFlag{
		Name:  metricutils.PrometheusExporterPortFlag,
		Usage: "Prometheus exporter listening port",
		Value: 61001,
	}
	// 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: "",
	}
	RPCVirtualHostsFlag = cli.StringFlag{
		Name:  "rpcvhosts",
		Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.",
		Value: strings.Join(node.DefaultConfig.HTTPVirtualHosts, ","),
	}
	RPCApiFlag = cli.StringFlag{
		Name:  "rpcapi",
		Usage: "API's offered over the HTTP-RPC interface",
		Value: "",
	}
	RPCGlobalGasCap = cli.Uint64Flag{
		Name:  "rpc.gascap",
		Usage: "Sets a cap on gas that can be used in klay_call/estimateGas",
	}
	RPCConcurrencyLimit = cli.IntFlag{
		Name:  "rpc.concurrencylimit",
		Usage: "Sets a limit of concurrent connection number of HTTP-RPC server",
		Value: rpc.ConcurrencyLimit,
	}
	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: "",
	}
	WSAllowedOriginsFlag = cli.StringFlag{
		Name:  "wsorigins",
		Usage: "Origins from which to accept websockets requests",
		Value: "",
	}
	WSMaxSubscriptionPerConn = cli.IntFlag{
		Name:  "wsmaxsubscriptionperconn",
		Usage: "Allowed maximum subscription number per a websocket connection",
		Value: 5,
	}
	WSReadDeadLine = cli.Int64Flag{
		Name:  "wsreaddeadline",
		Usage: "Set the read deadline on the underlying network connection in seconds. 0 means read will not timeout",
		Value: rpc.WebsocketReadDeadline,
	}
	WSWriteDeadLine = cli.Int64Flag{
		Name:  "wswritedeadline",
		Usage: "Set the Write deadline on the underlying network connection in seconds. 0 means write will not timeout",
		Value: rpc.WebsocketWriteDeadline,
	}
	WSMaxConnections = cli.IntFlag{
		Name:  "wsmaxconnections",
		Usage: "Allowed maximum websocket connection number",
		Value: 3000,
	}
	GRPCEnabledFlag = cli.BoolFlag{
		Name:  "grpc",
		Usage: "Enable the gRPC server",
	}
	GRPCListenAddrFlag = cli.StringFlag{
		Name:  "grpcaddr",
		Usage: "gRPC server listening interface",
		Value: node.DefaultGRPCHost,
	}
	GRPCPortFlag = cli.IntFlag{
		Name:  "grpcport",
		Usage: "gRPC server listening port",
		Value: node.DefaultGRPCPort,
	}
	IPCDisabledFlag = cli.BoolFlag{
		Name:  "ipcdisable",
		Usage: "Disable the IPC-RPC server",
	}
	IPCPathFlag = DirectoryFlag{
		Name:  "ipcpath",
		Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)",
	}
	ExecFlag = cli.StringFlag{
		Name:  "exec",
		Usage: "Execute JavaScript statement",
	}
	PreloadJSFlag = cli.StringFlag{
		Name:  "preload",
		Usage: "Comma separated list of JavaScript files to preload into the console",
	}
	APIFilterGetLogsDeadlineFlag = cli.DurationFlag{
		Name:  "api.filter.getLogs.deadline",
		Usage: "Execution deadline for log collecting filter APIs",
		Value: filters.GetLogsDeadline,
	}
	APIFilterGetLogsMaxItemsFlag = cli.IntFlag{
		Name:  "api.filter.getLogs.maxitems",
		Usage: "Maximum allowed number of return items for log collecting filter API",
		Value: filters.GetLogsMaxItems,
	}

	// Network Settings
	NodeTypeFlag = cli.StringFlag{
		Name:  "nodetype",
		Usage: "Klaytn node type (consensus node (cn), proxy node (pn), endpoint node (en))",
		Value: "en",
	}
	MaxConnectionsFlag = cli.IntFlag{
		Name:  "maxconnections",
		Usage: "Maximum number of physical connections. All single channel peers can be maxconnections peers. All multi channel peers can be maxconnections/2 peers. (network disabled if set to 0)",
		Value: node.DefaultMaxPhysicalConnections,
	}
	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: node.DefaultP2PPort,
	}
	SubListenPortFlag = cli.IntFlag{
		Name:  "subport",
		Usage: "Network sub listening port",
		Value: node.DefaultP2PSubPort,
	}
	MultiChannelUseFlag = cli.BoolFlag{
		Name:  "multichannel",
		Usage: "Create a dedicated channel for block propagation",
	}
	BootnodesFlag = cli.StringFlag{
		Name:  "bootnodes",
		Usage: "Comma separated kni 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)",
	}
	NetrestrictFlag = cli.StringFlag{
		Name:  "netrestrict",
		Usage: "Restricts network communication to the given IP network (CIDR masks)",
	}
	AnchoringPeriodFlag = cli.Uint64Flag{
		Name:  "chaintxperiod",
		Usage: "The period to make and send a chain transaction to the parent chain",
		Value: 1,
	}
	SentChainTxsLimit = cli.Uint64Flag{
		Name:  "chaintxlimit",
		Usage: "Number of service chain transactions stored for resending",
		Value: 100,
	}
	RWTimerIntervalFlag = cli.Uint64Flag{
		Name:  "rwtimerinterval",
		Usage: "Interval of using rw timer to check if it works well",
		Value: 1000,
	}
	RWTimerWaitTimeFlag = cli.DurationFlag{
		Name:  "rwtimerwaittime",
		Usage: "Wait time the rw timer waits for message writing",
		Value: 15 * time.Second,
	}
	MaxRequestContentLengthFlag = cli.IntFlag{
		Name:  "maxRequestContentLength",
		Usage: "Max request content length in byte for http, websocket and gRPC",
		Value: common.MaxRequestContentLength,
	}

	// ATM the url is left to the user and deployment to
	JSpathFlag = cli.StringFlag{
		Name:  "jspath",
		Usage: "JavaScript root path for `loadScript`",
		Value: ".",
	}
	CypressFlag = cli.BoolFlag{
		Name:  "cypress",
		Usage: "Pre-configured Klaytn Cypress network",
	}
	// Baobab bootnodes setting
	BaobabFlag = cli.BoolFlag{
		Name:  "baobab",
		Usage: "Pre-configured Klaytn baobab network",
	}
	// Bootnode's settings
	AuthorizedNodesFlag = cli.StringFlag{
		Name:  "authorized-nodes",
		Usage: "Comma separated kni URLs for authorized nodes list",
		Value: "",
	}
	//TODO-Klaytn-Bootnode the boodnode flags should be updated when it is implemented
	BNAddrFlag = cli.StringFlag{
		Name:  "bnaddr",
		Usage: `udp address to use node discovery`,
		Value: ":32323",
	}
	GenKeyFlag = cli.StringFlag{
		Name:  "genkey",
		Usage: "generate a node private key and write to given filename",
	}
	WriteAddressFlag = cli.BoolFlag{
		Name:  "writeaddress",
		Usage: `write out the node's public key which is given by "--nodekeyfile" or "--nodekeyhex"`,
	}
	// ServiceChain's settings
	MainBridgeFlag = cli.BoolFlag{
		Name:  "mainbridge",
		Usage: "Enable main bridge service for service chain",
	}
	SubBridgeFlag = cli.BoolFlag{
		Name:  "subbridge",
		Usage: "Enable sub bridge service for service chain",
	}
	MainBridgeListenPortFlag = cli.IntFlag{
		Name:  "mainbridgeport",
		Usage: "main bridge listen port",
		Value: 50505,
	}
	SubBridgeListenPortFlag = cli.IntFlag{
		Name:  "subbridgeport",
		Usage: "sub bridge listen port",
		Value: 50506,
	}
	ParentChainIDFlag = cli.IntFlag{
		Name:  "parentchainid",
		Usage: "parent chain ID",
		Value: 8217,
	}
	VTRecoveryFlag = cli.BoolFlag{
		Name:  "vtrecovery",
		Usage: "Enable value transfer recovery (default: false)",
	}
	VTRecoveryIntervalFlag = cli.Uint64Flag{
		Name:  "vtrecoveryinterval",
		Usage: "Set the value transfer recovery interval (seconds)",
		Value: 60,
	}
	ServiceChainNewAccountFlag = cli.BoolFlag{
		Name:  "scnewaccount",
		Usage: "Enable account creation for the service chain (default: false). If set true, generated account can't be synced with the parent chain.",
	}
	ServiceChainConsensusFlag = cli.StringFlag{
		Name:  "scconsensus",
		Usage: "Set the service chain consensus (\"istanbul\", \"clique\")",
		Value: "istanbul",
	}
	ServiceChainAnchoringFlag = cli.BoolFlag{
		Name:  "anchoring",
		Usage: "Enable anchoring for service chain",
	}
	// KAS
	KASServiceChainAnchorFlag = cli.BoolFlag{
		Name:  "kas.sc.anchor",
		Usage: "Enable KAS anchoring for service chain",
	}
	KASServiceChainAnchorPeriodFlag = cli.Uint64Flag{
		Name:  "kas.sc.anchor.period",
		Usage: "The period to anchor service chain blocks to KAS",
		Value: 1,
	}
	KASServiceChainAnchorUrlFlag = cli.StringFlag{
		Name:  "kas.sc.anchor.url",
		Usage: "The url for KAS anchor",
	}
	KASServiceChainAnchorOperatorFlag = cli.StringFlag{
		Name:  "kas.sc.anchor.operator",
		Usage: "The operator address for KAS anchor",
	}
	KASServiceChainXChainIdFlag = cli.StringFlag{
		Name:  "kas.x-chain-id",
		Usage: "The x-chain-id for KAS",
	}
	KASServiceChainAccessKeyFlag = cli.StringFlag{
		Name:  "kas.accesskey",
		Usage: "The access key id for KAS",
	}
	KASServiceChainSecretKeyFlag = cli.StringFlag{
		Name:  "kas.secretkey",
		Usage: "The secret key for KAS",
	}

	// ChainDataFetcher
	EnableChainDataFetcherFlag = cli.BoolFlag{
		Name:  "chaindatafetcher",
		Usage: "Enable the ChainDataFetcher Service",
	}
	ChainDataFetcherMode = cli.StringFlag{
		Name:  "chaindatafetcher.mode",
		Usage: "The mode of chaindatafetcher (\"kas\", \"kafka\")",
		Value: "kas",
	}
	ChainDataFetcherNoDefault = cli.BoolFlag{
		Name:  "chaindatafetcher.no.default",
		Usage: "Turn off the starting of the chaindatafetcher",
	}
	ChainDataFetcherNumHandlers = cli.IntFlag{
		Name:  "chaindatafetcher.num.handlers",
		Usage: "Number of chaindata handlers",
		Value: chaindatafetcher.DefaultNumHandlers,
	}
	ChainDataFetcherJobChannelSize = cli.IntFlag{
		Name:  "chaindatafetcher.job.channel.size",
		Usage: "Job channel size",
		Value: chaindatafetcher.DefaultJobChannelSize,
	}
	ChainDataFetcherChainEventSizeFlag = cli.IntFlag{
		Name:  "chaindatafetcher.block.channel.size",
		Usage: "Block received channel size",
		Value: chaindatafetcher.DefaultJobChannelSize,
	}
	ChainDataFetcherKASDBHostFlag = cli.StringFlag{
		Name:  "chaindatafetcher.kas.db.host",
		Usage: "KAS specific DB host in chaindatafetcher",
	}
	ChainDataFetcherKASDBPortFlag = cli.StringFlag{
		Name:  "chaindatafetcher.kas.db.port",
		Usage: "KAS specific DB port in chaindatafetcher",
		Value: chaindatafetcher.DefaultDBPort,
	}
	ChainDataFetcherKASDBNameFlag = cli.StringFlag{
		Name:  "chaindatafetcher.kas.db.name",
		Usage: "KAS specific DB name in chaindatafetcher",
	}
	ChainDataFetcherKASDBUserFlag = cli.StringFlag{
		Name:  "chaindatafetcher.kas.db.user",
		Usage: "KAS specific DB user in chaindatafetcher",
	}
	ChainDataFetcherKASDBPasswordFlag = cli.StringFlag{
		Name:  "chaindatafetcher.kas.db.password",
		Usage: "KAS specific DB password in chaindatafetcher",
	}
	ChainDataFetcherKASCacheUse = cli.BoolFlag{
		Name:  "chaindatafetcher.kas.cache.use",
		Usage: "Enable KAS cache invalidation",
	}
	ChainDataFetcherKASCacheURLFlag = cli.StringFlag{
		Name:  "chaindatafetcher.kas.cache.url",
		Usage: "KAS specific cache invalidate API endpoint in chaindatafetcher",
	}
	ChainDataFetcherKASXChainIdFlag = cli.StringFlag{
		Name:  "chaindatafetcher.kas.xchainid",
		Usage: "KAS specific header x-chain-id in chaindatafetcher",
	}
	ChainDataFetcherKASBasicAuthParamFlag = cli.StringFlag{
		Name:  "chaindatafetcher.kas.basic.auth.param",
		Usage: "KAS specific header basic authorization parameter in chaindatafetcher",
	}
	ChainDataFetcherKafkaBrokersFlag = cli.StringSliceFlag{
		Name:  "chaindatafetcher.kafka.brokers",
		Usage: "Kafka broker URL list",
	}
	ChainDataFetcherKafkaTopicEnvironmentFlag = cli.StringFlag{
		Name:  "chaindatafetcher.kafka.topic.environment",
		Usage: "Kafka topic environment prefix",
		Value: kafka.DefaultTopicEnvironmentName,
	}
	ChainDataFetcherKafkaTopicResourceFlag = cli.StringFlag{
		Name:  "chaindatafetcher.kafka.topic.resource",
		Usage: "Kafka topic resource name",
		Value: kafka.DefaultTopicResourceName,
	}
	ChainDataFetcherKafkaReplicasFlag = cli.Int64Flag{
		Name:  "chaindatafetcher.kafka.replicas",
		Usage: "Kafka partition replication factor",
		Value: kafka.DefaultReplicas,
	}
	ChainDataFetcherKafkaPartitionsFlag = cli.IntFlag{
		Name:  "chaindatafetcher.kafka.partitions",
		Usage: "The number of partitions in a topic",
		Value: kafka.DefaultPartitions,
	}
	ChainDataFetcherKafkaMaxMessageBytesFlag = cli.Int64Flag{
		Name:  "chaindatafetcher.kafka.max.message.bytes",
		Usage: "The max size of a message produced by Kafka producer ",
		Value: kafka.DefaultMaxMessageBytes,
	}
	ChainDataFetcherKafkaSegmentSizeBytesFlag = cli.IntFlag{
		Name:  "chaindatafetcher.kafka.segment.size",
		Usage: "The kafka data segment size (in byte)",
		Value: kafka.DefaultSegmentSizeBytes,
	}
	ChainDataFetcherKafkaRequiredAcksFlag = cli.IntFlag{
		Name:  "chaindatafetcher.kafka.required.acks",
		Usage: "The level of acknowledgement reliability needed from Kafka broker (0: NoResponse, 1: WaitForLocal, -1: WaitForAll)",
		Value: kafka.DefaultRequiredAcks,
	}
	// DBSyncer
	EnableDBSyncerFlag = cli.BoolFlag{
		Name:  "dbsyncer",
		Usage: "Enable the DBSyncer",
	}
	DBHostFlag = cli.StringFlag{
		Name:  "dbsyncer.db.host",
		Usage: "db.host in dbsyncer",
	}
	DBPortFlag = cli.StringFlag{
		Name:  "dbsyncer.db.port",
		Usage: "db.port in dbsyncer",
		Value: "3306",
	}
	DBNameFlag = cli.StringFlag{
		Name:  "dbsyncer.db.name",
		Usage: "db.name in dbsyncer",
	}
	DBUserFlag = cli.StringFlag{
		Name:  "dbsyncer.db.user",
		Usage: "db.user in dbsyncer",
	}
	DBPasswordFlag = cli.StringFlag{
		Name:  "dbsyncer.db.password",
		Usage: "db.password in dbsyncer",
	}
	EnabledLogModeFlag = cli.BoolFlag{
		Name:  "dbsyncer.logmode",
		Usage: "Enable the dbsyncer logmode",
	}
	MaxIdleConnsFlag = cli.IntFlag{
		Name:  "dbsyncer.db.max.idle",
		Usage: "The maximum number of connections in the idle connection pool",
		Value: 50,
	}
	MaxOpenConnsFlag = cli.IntFlag{
		Name:  "dbsyncer.db.max.open",
		Usage: "The maximum number of open connections to the database",
		Value: 30,
	}
	ConnMaxLifeTimeFlag = cli.DurationFlag{
		Name:  "dbsyncer.db.max.lifetime",
		Usage: "The maximum amount of time a connection may be reused (default : 1h), ex: 300ms, 2h45m, 60s, ...",
		Value: 1 * time.Hour,
	}
	BlockSyncChannelSizeFlag = cli.IntFlag{
		Name:  "dbsyncer.block.channel.size",
		Usage: "Block received channel size",
		Value: 5,
	}
	DBSyncerModeFlag = cli.StringFlag{
		Name:  "dbsyncer.mode",
		Usage: "The mode of dbsyncer is way which handle block/tx data to insert db (multi, single, context)",
		Value: "multi",
	}
	GenQueryThreadFlag = cli.IntFlag{
		Name:  "dbsyncer.genquery.th",
		Usage: "The amount of thread of generation query in multi mode",
		Value: 50,
	}
	InsertThreadFlag = cli.IntFlag{
		Name:  "dbsyncer.insert.th",
		Usage: "The amount of thread of insert operation in multi mode",
		Value: 30,
	}
	BulkInsertSizeFlag = cli.IntFlag{
		Name:  "dbsyncer.bulk.size",
		Usage: "The amount of row for bulk-insert",
		Value: 200,
	}
	EventModeFlag = cli.StringFlag{
		Name:  "dbsyncer.event.mode",
		Usage: "The way how to sync all block or last block (block, head)",
		Value: "head",
	}
	MaxBlockDiffFlag = cli.Uint64Flag{
		Name:  "dbsyncer.max.block.diff",
		Usage: "The maximum difference between current block and event block. 0 means off",
		Value: 0,
	}
	AutoRestartFlag = cli.BoolFlag{
		Name:  "autorestart.enable",
		Usage: "Node can restart itself when there is a problem in making consensus",
	}
	RestartTimeOutFlag = cli.DurationFlag{
		Name:  "autorestart.timeout",
		Usage: "The elapsed time to wait auto restart (minutes)",
		Value: 15 * time.Minute,
	}
	DaemonPathFlag = cli.StringFlag{
		Name:  "autorestart.daemon.path",
		Usage: "Path of node daemon. Used to give signal to kill",
		Value: "~/klaytn/bin/kcnd",
	}

	// db migration vars
	DstDbTypeFlag = cli.StringFlag{
		Name:  "dst.dbtype",
		Usage: `Blockchain storage database type ("LevelDB", "BadgerDB", "DynamoDBS3")`,
		Value: "LevelDB",
	}
	DstDataDirFlag = DirectoryFlag{
		Name:  "dst.datadir",
		Usage: "Data directory for the databases and keystore. This value is only used in local DB.",
	}
	DstSingleDBFlag = cli.BoolFlag{
		Name:  "db.dst.single",
		Usage: "Create a single persistent storage. MiscDB, headerDB and etc are stored in one DB.",
	}
	DstLevelDBCacheSizeFlag = cli.IntFlag{
		Name:  "db.dst.leveldb.cache-size",
		Usage: "Size of in-memory cache in LevelDB (MiB)",
		Value: 768,
	}
	DstLevelDBCompressionTypeFlag = cli.IntFlag{
		Name:  "db.dst.leveldb.compression",
		Usage: "Determines the compression method for LevelDB. 0=AllNoCompression, 1=ReceiptOnlySnappyCompression, 2=StateTrieOnlyNoCompression, 3=AllSnappyCompression",
		Value: 0,
	}
	DstNumStateTrieShardsFlag = cli.UintFlag{
		Name:  "db.dst.num-statetrie-shards",
		Usage: "Number of internal shards of state trie DB shards. Should be power of 2",
		Value: 4,
	}
	DstDynamoDBTableNameFlag = cli.StringFlag{
		Name:  "db.dst.dynamo.tablename",
		Usage: "Specifies DynamoDB table name. This is mandatory to use dynamoDB. (Set dbtype to use DynamoDBS3). If dstDB is singleDB, tableName should be in form of 'PREFIX-TABLENAME'.(e.g. 'klaytn-misc', 'klaytn-statetrie')",
	}
	DstDynamoDBRegionFlag = cli.StringFlag{
		Name:  "db.dst.dynamo.region",
		Usage: "AWS region where the DynamoDB will be created.",
		Value: database.GetDefaultDynamoDBConfig().Region,
	}
	DstDynamoDBIsProvisionedFlag = cli.BoolFlag{
		Name:  "db.dst.dynamo.is-provisioned",
		Usage: "Set DynamoDB billing mode to provision. The default billing mode is on-demand.",
	}
	DstDynamoDBReadCapacityFlag = cli.Int64Flag{
		Name:  "db.dst.dynamo.read-capacity",
		Usage: "Read capacity unit of dynamoDB. If is-provisioned is not set, this flag will not be applied.",
		Value: database.GetDefaultDynamoDBConfig().ReadCapacityUnits,
	}
	DstDynamoDBWriteCapacityFlag = cli.Int64Flag{
		Name:  "db.dst.dynamo.write-capacity",
		Usage: "Write capacity unit of dynamoDB. If is-provisioned is not set, this flag will not be applied",
		Value: database.GetDefaultDynamoDBConfig().WriteCapacityUnits,
	}

	// Config
	ConfigFileFlag = cli.StringFlag{
		Name:  "config",
		Usage: "TOML configuration file",
	}
)
View Source
var (
	GlobalAppHelpTemplate = `` /* 637-byte string literal not displayed */

	CommandHelpTemplate = `` /* 471-byte string literal not displayed */

	AppHelpTemplate = `` /* 308-byte string literal not displayed */

	KgenHelpTemplate = `` /* 330-byte string literal not displayed */

)

GlobalAppHelpTemplate is the test template for the default, global app help topic.

View Source
var FlagGroups = []FlagGroup{
	{
		Name: "KLAY",
		Flags: []cli.Flag{
			DbTypeFlag,
			DataDirFlag,
			KeyStoreDirFlag,
			IdentityFlag,
			SyncModeFlag,
			GCModeFlag,
			LightKDFFlag,
			SrvTypeFlag,
			ExtraDataFlag,
			ConfigFileFlag,
			OverwriteGenesisFlag,
			StartBlockNumberFlag,
		},
	},
	{
		Name: "ACCOUNT",
		Flags: []cli.Flag{
			UnlockedAccountFlag,
			PasswordFileFlag,
		},
	},
	{
		Name: "TXPOOL",
		Flags: []cli.Flag{
			TxPoolNoLocalsFlag,
			TxPoolAllowLocalAnchorTxFlag,
			TxPoolJournalFlag,
			TxPoolJournalIntervalFlag,
			TxPoolPriceLimitFlag,
			TxPoolPriceBumpFlag,
			TxPoolExecSlotsAccountFlag,
			TxPoolExecSlotsAllFlag,
			TxPoolNonExecSlotsAccountFlag,
			TxPoolNonExecSlotsAllFlag,
			TxPoolLifetimeFlag,
			TxPoolKeepLocalsFlag,
			TxResendIntervalFlag,
			TxResendCountFlag,
			TxResendUseLegacyFlag,
		},
	},
	{
		Name: "DATABASE",
		Flags: []cli.Flag{
			LevelDBCacheSizeFlag,
			SingleDBFlag,
			NumStateTrieShardsFlag,
			LevelDBCompressionTypeFlag,
			LevelDBNoBufferPoolFlag,
			DynamoDBTableNameFlag,
			DynamoDBRegionFlag,
			DynamoDBIsProvisionedFlag,
			DynamoDBReadCapacityFlag,
			DynamoDBWriteCapacityFlag,
			NoParallelDBWriteFlag,
			SenderTxHashIndexingFlag,
			DBNoPerformanceMetricsFlag,
		},
	},
	{
		Name: "DATABASE SYNCER",
		Flags: []cli.Flag{
			EnableDBSyncerFlag,
			DBHostFlag,
			DBPortFlag,
			DBNameFlag,
			DBUserFlag,
			DBPasswordFlag,
			EnabledLogModeFlag,
			MaxIdleConnsFlag,
			MaxOpenConnsFlag,
			ConnMaxLifeTimeFlag,
			BlockSyncChannelSizeFlag,
			DBSyncerModeFlag,
			GenQueryThreadFlag,
			InsertThreadFlag,
			BulkInsertSizeFlag,
			EventModeFlag,
			MaxBlockDiffFlag,
		},
	},
	{
		Name: "CHAINDATAFETCHER",
		Flags: []cli.Flag{
			EnableChainDataFetcherFlag,
			ChainDataFetcherMode,
			ChainDataFetcherNoDefault,
			ChainDataFetcherNumHandlers,
			ChainDataFetcherJobChannelSize,
			ChainDataFetcherChainEventSizeFlag,
			ChainDataFetcherKASDBHostFlag,
			ChainDataFetcherKASDBPortFlag,
			ChainDataFetcherKASDBNameFlag,
			ChainDataFetcherKASDBUserFlag,
			ChainDataFetcherKASDBPasswordFlag,
			ChainDataFetcherKASCacheUse,
			ChainDataFetcherKASCacheURLFlag,
			ChainDataFetcherKASXChainIdFlag,
			ChainDataFetcherKASBasicAuthParamFlag,
			ChainDataFetcherKafkaBrokersFlag,
			ChainDataFetcherKafkaTopicEnvironmentFlag,
			ChainDataFetcherKafkaTopicResourceFlag,
			ChainDataFetcherKafkaReplicasFlag,
			ChainDataFetcherKafkaPartitionsFlag,
			ChainDataFetcherKafkaMaxMessageBytesFlag,
			ChainDataFetcherKafkaSegmentSizeBytesFlag,
			ChainDataFetcherKafkaRequiredAcksFlag,
		},
	},
	{
		Name: "DATABASE MIGRATION",
		Flags: []cli.Flag{
			DstDbTypeFlag,
			DstDataDirFlag,
			DstSingleDBFlag,
			DstLevelDBCompressionTypeFlag,
			DstNumStateTrieShardsFlag,
			DstDynamoDBTableNameFlag,
			DstDynamoDBRegionFlag,
			DstDynamoDBIsProvisionedFlag,
			DstDynamoDBReadCapacityFlag,
			DstDynamoDBWriteCapacityFlag,
		},
	},
	{
		Name: "STATE",
		Flags: []cli.Flag{
			TrieMemoryCacheSizeFlag,
			TrieBlockIntervalFlag,
			TriesInMemoryFlag,
		},
	},
	{
		Name: "CACHE",
		Flags: []cli.Flag{
			CacheTypeFlag,
			CacheScaleFlag,
			CacheUsageLevelFlag,
			MemorySizeFlag,
			TrieNodeCacheTypeFlag,
			NumFetcherPrefetchWorkerFlag,
			TrieNodeCacheLimitFlag,
			TrieNodeCacheSavePeriodFlag,
			TrieNodeCacheRedisEndpointsFlag,
			TrieNodeCacheRedisClusterFlag,
			TrieNodeCacheRedisPublishBlockFlag,
			TrieNodeCacheRedisSubscribeBlockFlag,
		},
	},
	{
		Name: "CONSENSUS",
		Flags: []cli.Flag{
			ServiceChainSignerFlag,
			RewardbaseFlag,
		},
	},
	{
		Name: "NETWORKING",
		Flags: []cli.Flag{
			BootnodesFlag,
			ListenPortFlag,
			SubListenPortFlag,
			MultiChannelUseFlag,
			MaxConnectionsFlag,
			MaxPendingPeersFlag,
			TargetGasLimitFlag,
			NATFlag,
			NoDiscoverFlag,
			RWTimerWaitTimeFlag,
			RWTimerIntervalFlag,
			NetrestrictFlag,
			NodeKeyFileFlag,
			NodeKeyHexFlag,
			NetworkIdFlag,
			BaobabFlag,
			CypressFlag,
		},
	},
	{
		Name: "METRICS",
		Flags: []cli.Flag{
			MetricsEnabledFlag,
			PrometheusExporterFlag,
			PrometheusExporterPortFlag,
		},
	},
	{
		Name: "VIRTUAL MACHINE",
		Flags: []cli.Flag{
			VMEnableDebugFlag,
			VMLogTargetFlag,
			VMTraceInternalTxFlag,
		},
	},
	{
		Name: "API AND CONSOLE",
		Flags: []cli.Flag{
			RPCEnabledFlag,
			RPCListenAddrFlag,
			RPCPortFlag,
			RPCCORSDomainFlag,
			RPCVirtualHostsFlag,
			RPCApiFlag,
			RPCGlobalGasCap,
			RPCConcurrencyLimit,
			IPCDisabledFlag,
			IPCPathFlag,
			WSEnabledFlag,
			WSListenAddrFlag,
			WSPortFlag,
			WSApiFlag,
			WSAllowedOriginsFlag,
			GRPCEnabledFlag,
			GRPCListenAddrFlag,
			GRPCPortFlag,
			JSpathFlag,
			ExecFlag,
			PreloadJSFlag,
			MaxRequestContentLengthFlag,
			APIFilterGetLogsDeadlineFlag,
			APIFilterGetLogsMaxItemsFlag,
		},
	},
	{
		Name:  "LOGGING AND DEBUGGING",
		Flags: debug.Flags,
	},
	{
		Name: "SERVICECHAIN",
		Flags: []cli.Flag{
			ChildChainIndexingFlag,
			MainBridgeFlag,
			MainBridgeListenPortFlag,
			SubBridgeFlag,
			SubBridgeListenPortFlag,
			AnchoringPeriodFlag,
			SentChainTxsLimit,
			ParentChainIDFlag,
			VTRecoveryFlag,
			VTRecoveryIntervalFlag,
			ServiceChainAnchoringFlag,
			ServiceChainNewAccountFlag,
			KASServiceChainAnchorFlag,
			KASServiceChainAnchorPeriodFlag,
			KASServiceChainAnchorUrlFlag,
			KASServiceChainAnchorOperatorFlag,
			KASServiceChainAccessKeyFlag,
			KASServiceChainSecretKeyFlag,
			KASServiceChainXChainIdFlag,
		},
	},
	{
		Name: "MISC",
		Flags: []cli.Flag{
			GenKeyFlag,
			WriteAddressFlag,
			AutoRestartFlag,
			RestartTimeOutFlag,
			DaemonPathFlag,
			KESNodeTypeServiceFlag,
		},
	},
}

TODO-Klaytn: consider changing the type of FlagGroups to map FlagGroups categorizes flags into groups to print structured help.

Functions

func CheckExclusive added in v1.6.0

func CheckExclusive(ctx *cli.Context, args ...interface{})

CheckExclusive verifies that only a single instance of the provided flags was set by the user. Each flag might optionally be followed by a string type to specialize it further.

func ExportAppendChain

func ExportAppendChain(blockchain *blockchain.BlockChain, fn string, first uint64, last uint64) error

ExportAppendChain exports a blockchain into the specified file, appending to the file if data already exists in it.

func ExportChain

func ExportChain(blockchain *blockchain.BlockChain, fn string) error

ExportChain exports a blockchain into the specified file, truncating any data already present in the file.

func FormatPackage

func FormatPackage(name string) string

func GlobalBig

func GlobalBig(ctx *cli.Context, name string) *big.Int

GlobalBig returns the value of a BigFlag from the global flag set.

func ImportChain

func ImportChain(chain *blockchain.BlockChain, fn string) error

func InitHelper

func InitHelper()

func MakeAddress

func MakeAddress(ks *keystore.KeyStore, account string) (accounts.Account, error)

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 MakeConsolePreloads

func MakeConsolePreloads(ctx *cli.Context) []string

MakeConsolePreloads retrieves the absolute paths for the console JavaScript scripts to preload before starting.

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 baobab, the a subdirectory of the specified datadir will be used.

func MakePasswordList

func MakePasswordList(ctx *cli.Context) []string

MakePasswordList reads password lines from the file specified by the global --password flag.

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. ken account new --keystore /tmp/mykeystore --lightkdf

is equivalent after calling this method with:

ken --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 NewCLI

func NewCLI() *cli.App

NewApp creates an app with sane defaults.

func NewHelpPrinter

func NewHelpPrinter(fg []FlagGroup) func(w io.Writer, tmp string, data interface{})

func RegisterCNService

func RegisterCNService(stack *node.Node, cfg *cn.Config)

RegisterCNService adds a CN client to the stack.

func RegisterChainDataFetcherService added in v1.5.2

func RegisterChainDataFetcherService(stack *node.Node, cfg *chaindatafetcher.ChainDataFetcherConfig)

RegisterChainDataFetcherService adds a ChainDataFetcher to the stack

func RegisterDBSyncerService

func RegisterDBSyncerService(stack *node.Node, cfg *dbsyncer.DBConfig)

RegisterDBSyncerService adds a DBSyncer to the stack

func RegisterService

func RegisterService(stack *node.Node, cfg *sc.SCConfig)

func SetKlayConfig

func SetKlayConfig(ctx *cli.Context, stack *node.Node, cfg *cn.Config)

SetKlayConfig applies klay-related command line flags to the config.

func SetNodeConfig

func SetNodeConfig(ctx *cli.Context, cfg *node.Config)

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

func SetP2PConfig

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

func SetupNetwork

func SetupNetwork(ctx *cli.Context)

SetupNetwork configures the system for either the main net or some test network.

func SplitAndJoin

func SplitAndJoin(s string, symbol string) string

SplitAndJoin converts a camel-case string to a string joined by the provided symbol

func StartNode

func StartNode(stack *node.Node)

func ToCamelCase

func ToCamelCase(inputUnderScoreStr string) (camelCase string)

ToCamelCase converts an under-score string to a camel-case string

func ToHyphen

func ToHyphen(s string) string

ToHyphen converts a camel-case string to a hyphen-style string

func ToUnderScore

func ToUnderScore(s string) string

ToUnderScore converts a camel-case string to a under-score string

func WriteFile

func WriteFile(content, filePath, fileName string)

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. ~/.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) 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 FlagGroup

type FlagGroup struct {
	Name  string
	Flags []cli.Flag
}

FlagGroup is a collection of flags belonging to a single topic.

func CategorizeFlags added in v1.5.3

func CategorizeFlags(flags []cli.Flag) []FlagGroup

CategorizeFlags classifies each flag into pre-defined flagGroups.

type TestCmd

type TestCmd struct {
	// For total convenience, all testing methods are available.
	*testing.T

	Func    template.FuncMap
	Data    interface{}
	Cleanup func()
	// contains filtered or unexported fields
}

func NewTestCmd

func NewTestCmd(t *testing.T, data interface{}) *TestCmd

func (*TestCmd) CloseStdin

func (tt *TestCmd) CloseStdin()

func (*TestCmd) Expect

func (tt *TestCmd) Expect(tplsource string)

Expect runs its argument as a template, then expects the child process to output the result of the template within 5s.

If the template starts with a newline, the newline is removed before matching.

func (*TestCmd) ExpectExit

func (tt *TestCmd) ExpectExit()

ExpectExit expects the child process to exit within 5s without printing any additional text on stdout.

func (*TestCmd) ExpectRegexp

func (tt *TestCmd) ExpectRegexp(regex string) (*regexp.Regexp, []string)

ExpectRegexp expects the child process to output text matching the given regular expression within 5s.

Note that an arbitrary amount of output may be consumed by the regular expression. This usually means that expect cannot be used after ExpectRegexp.

func (*TestCmd) InputLine

func (tt *TestCmd) InputLine(s string) string

InputLine writes the given text to the childs stdin. This method can also be called from an expect template, e.g.:

klay.expect(`Passphrase: {{.InputLine "password"}}`)

func (*TestCmd) Interrupt

func (tt *TestCmd) Interrupt()

func (*TestCmd) Kill

func (tt *TestCmd) Kill()

func (*TestCmd) Run

func (tt *TestCmd) Run(name string, args ...string)

Run exec's the current binary using name as argv[0] which will trigger the reexec init function for that name (e.g. "klay-test" in cmd/utils/nodecmd/run_test.go)

func (*TestCmd) SetTemplateFunc

func (tt *TestCmd) SetTemplateFunc(name string, fn interface{})

func (*TestCmd) StderrText

func (tt *TestCmd) StderrText() string

StderrText returns any stderr output written so far. The returned text holds all log lines after ExpectExit has returned.

func (*TestCmd) WaitExit

func (tt *TestCmd) WaitExit()

type TextMarshaler

type TextMarshaler interface {
	encoding.TextMarshaler
	encoding.TextUnmarshaler
}

func GlobalTextMarshaler

func GlobalTextMarshaler(ctx *cli.Context, name string) TextMarshaler

GlobalTextMarshaler returns the value of a TextMarshalerFlag from the global flag set.

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

Directories

Path Synopsis
Package nodecmd contains command definitions and related functions used for node cmds, such as kcn, kpn, and ken.
Package nodecmd contains command definitions and related functions used for node cmds, such as kcn, kpn, and ken.

Jump to

Keyboard shortcuts

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