Documentation ¶
Overview ¶
The commands from the SDK are defined with `cobra` and configured with the `viper` package.
This takes place in the `InterceptConfigsPreRunHandler` function. Since the `viper` package is used for configuration the precedence is dictated by that package. That is
1. Command line switches 2. Environment variables 3. Files from configuration values 4. Default values
The global configuration instance exposed by the `viper` package is not used by Cosmos SDK in this function. A new instance of `viper.Viper` is created and the following is performed. The environmental variable prefix is set to the current program name. Environmental variables consider the underscore to be equivalent to the `.` or `-` character. This means that an configuration value called `rpc.laddr` would be read from an environmental variable called `MYTOOL_RPC_LADDR` if the current program name is `mytool`.
Running the `InterceptConfigsPreRunHandler` also reads `app.toml` and `config.toml` from the home directory under the `config` directory. If `config.toml` or `app.toml` do not exist then those files are created and populated with default values. `InterceptConfigsPreRunHandler` takes two parameters to set/update a custom template to create custom `app.toml`. If these parameters are empty, the server then creates a default template provided by the SDK.
Index ¶
- Constants
- func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator types.AppCreator, ...)
- func ExportCmd(appExporter types.AppExporter, defaultNodeHome string) *cobra.Command
- func ExternalIP() (string, error)
- func FreeTCPAddr() (addr, port string, err error)
- func GenerateCoinKey(algo keyring.SignatureAlgo) (sdk.AccAddress, string, error)deprecated
- func GenerateSaveCoinKey(keybase keyring.Keyring, keyName string, overwrite bool, ...) (sdk.AccAddress, string, error)deprecated
- func GetPruningOptionsFromFlags(appOpts types.AppOptions) (storetypes.PruningOptions, error)
- func InterceptConfigsPreRunHandler(cmd *cobra.Command, customAppConfigTemplate string, ...) error
- func ListenForQuitSignals(g *errgroup.Group, block bool, cancelFn context.CancelFunc, ...)
- func NewRollbackCmd(appCreator types.AppCreator, defaultNodeHome string) *cobra.Command
- func SetCmdServerContext(cmd *cobra.Command, serverCtx *Context) error
- func SetupTraceWriter(logger tmlog.Logger, traceWriterFile string) (traceWriter io.WriteCloser, cleanup func(), err error)
- func ShowAddressCmd() *cobra.Command
- func ShowNodeIDCmd() *cobra.Command
- func ShowValidatorCmd() *cobra.Command
- func StartCmd(appCreator types.AppCreator, defaultNodeHome string) *cobra.Command
- func TrapSignal(cleanupFunc func())
- func VersionCmd() *cobra.Command
- type Context
- type ErrorCode
Constants ¶
const ( FlagHeight = "height" FlagForZeroHeight = "for-zero-height" FlagJailAllowedAddrs = "jail-allowed-addrs" )
const ( FlagMinGasPrices = "minimum-gas-prices" FlagHaltHeight = "halt-height" FlagHaltTime = "halt-time" FlagInterBlockCache = "inter-block-cache" FlagInterBlockCacheSize = "inter-block-cache-size" FlagUnsafeSkipUpgrades = "unsafe-skip-upgrades" FlagTrace = "trace" FlagInvCheckPeriod = "inv-check-period" FlagPrometheus = "prometheus" FlagChanCheckTxSize = "chan-check-tx-size" FlagPruning = "pruning" FlagPruningKeepRecent = "pruning-keep-recent" FlagPruningKeepEvery = "pruning-keep-every" FlagPruningInterval = "pruning-interval" FlagIndexEvents = "index-events" FlagMinRetainBlocks = "min-retain-blocks" FlagIAVLCacheSize = "iavl-cache-size" FlagIAVLFastNode = "iavl-disable-fastnode" // state sync-related flags FlagStateSyncSnapshotInterval = "state-sync.snapshot-interval" FlagStateSyncSnapshotKeepRecent = "state-sync.snapshot-keep-recent" )
Ostracon full-node start flags
const ServerContextKey = sdk.ContextKey("server.context")
ServerContextKey defines the context key used to retrieve a server.Context from a command's Context.
Variables ¶
This section is empty.
Functions ¶
func AddCommands ¶
func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator types.AppCreator, appExport types.AppExporter, addStartFlags types.ModuleInitFlags)
add server commands
func ExportCmd ¶ added in v0.16.0
func ExportCmd(appExporter types.AppExporter, defaultNodeHome string) *cobra.Command
ExportCmd dumps app state to JSON.
func ExternalIP ¶ added in v0.25.0
https://stackoverflow.com/questions/23558425/how-do-i-get-the-local-ip-address-in-go TODO there must be a better way to get external IP
func FreeTCPAddr ¶
Get a free address for a test ostracon server protocol is either tcp, http, etc
func GenerateCoinKey
deprecated
func GenerateCoinKey(algo keyring.SignatureAlgo) (sdk.AccAddress, string, error)
Deprecated: GenerateCoinKey generates a new key mnemonic along with its addrress. Please use testutils.GenerateCoinKey instead.
func GenerateSaveCoinKey
deprecated
added in
v0.16.0
func GenerateSaveCoinKey( keybase keyring.Keyring, keyName string, overwrite bool, algo keyring.SignatureAlgo, ) (sdk.AccAddress, string, error)
Deprecated: GenerateSaveCoinKey generates a new key mnemonic with its addrress. If mnemonic is provided then it's used for key generation. The key is saved in the keyring. The function returns error if overwrite=true and the key already exists. Please use testutils.GenerateSaveCoinKey instead.
func GetPruningOptionsFromFlags ¶ added in v0.47.0
func GetPruningOptionsFromFlags(appOpts types.AppOptions) (storetypes.PruningOptions, error)
GetPruningOptionsFromFlags parses command flags and returns the correct PruningOptions. If a pruning strategy is provided, that will be parsed and returned, otherwise, it is assumed custom pruning options are provided.
func InterceptConfigsPreRunHandler ¶ added in v0.47.0
func InterceptConfigsPreRunHandler(cmd *cobra.Command, customAppConfigTemplate string, customAppConfig interface{}) error
InterceptConfigsPreRunHandler performs a pre-run function for the root daemon application command. It will create a Viper literal and a default server Context. The server Tendermint configuration will either be read and parsed or created and saved to disk, where the server Context is updated to reflect the Tendermint configuration. It takes custom app config template and config settings to create a custom Tendermint configuration. If the custom template is empty, it uses default-template provided by the server. The Viper literal is used to read and parse the application configuration. Command handlers can fetch the server Context to get the Tendermint configuration or to get access to Viper.
func ListenForQuitSignals ¶ added in v0.49.1
func ListenForQuitSignals(g *errgroup.Group, block bool, cancelFn context.CancelFunc, logger tmlog.Logger)
ListenForQuitSignals listens for SIGINT and SIGTERM. When a signal is received, the cleanup function is called, indicating the caller can gracefully exit or return.
Note, the blocking behavior of this depends on the block argument. The caller must ensure the corresponding context derived from the cancelFn is used correctly.
func NewRollbackCmd ¶ added in v0.47.0
func NewRollbackCmd(appCreator types.AppCreator, defaultNodeHome string) *cobra.Command
NewRollbackCmd creates a command to rollback tendermint and multistore state by one height.
func SetCmdServerContext ¶ added in v0.47.0
SetCmdServerContext sets a command's Context value to the provided argument.
func SetupTraceWriter ¶ added in v0.49.1
func SetupTraceWriter(logger tmlog.Logger, traceWriterFile string) (traceWriter io.WriteCloser, cleanup func(), err error)
SetupTraceWriter sets up the trace writer and returns a cleanup function.
func ShowAddressCmd ¶ added in v0.25.0
ShowAddressCmd - show this node's validator address
func ShowNodeIDCmd ¶
ShowNodeIDCmd - ported from Ostracon, dump node ID to stdout
func ShowValidatorCmd ¶
ShowValidatorCmd - ported from Ostracon, show this node's validator info
func StartCmd ¶
func StartCmd(appCreator types.AppCreator, defaultNodeHome string) *cobra.Command
StartCmd runs the service passed in, either stand-alone or in-process with Ostracon.
func TrapSignal ¶ added in v0.26.0
func TrapSignal(cleanupFunc func())
TrapSignal traps SIGINT and SIGTERM and terminates the server correctly.
func VersionCmd ¶ added in v0.30.0
VersionCmd prints ostracon and ABCI version numbers.
Types ¶
type Context ¶
server context
func GetServerContextFromCmd ¶ added in v0.47.0
GetServerContextFromCmd returns a Context from a command or an empty Context if it has not been set.
func NewContext ¶
func NewDefaultContext ¶
func NewDefaultContext() *Context
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
gogoreflection
Package gogoreflection implements gRPC reflection for gogoproto consumers the normal reflection library does not work as it points to a different singleton registry.
|
Package gogoreflection implements gRPC reflection for gogoproto consumers the normal reflection library does not work as it points to a different singleton registry. |
reflection/v2
Package v2 is a reverse proxy.
|
Package v2 is a reverse proxy. |