common

package
v0.2202.6 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: Apache-2.0 Imports: 21 Imported by: 9

Documentation

Overview

Package common implements common oasis-node command options and utilities.

Index

Constants

View Source
const (
	// CfgDebugAllowTestKeys is the command line flag to enable the debug test
	// keys.
	CfgDebugAllowTestKeys = "debug.allow_test_keys"
	// CfgDebugAllowDebugEnclaves is the command line flag to enable debug enclaves.
	CfgDebugAllowDebugEnclaves = "debug.allow_debug_enclaves"

	// CfgDebugRlimit is the command flag to set RLIMIT_NOFILE on launch.
	CfgDebugRlimit = "debug.rlimit"

	CfgConfigFile = "config"
	CfgDataDir    = "datadir"

	// RequiredRlimit is the minimum required RLIMIT_NOFILE as too low of a
	// limit can cause problems with BadgerDB.
	RequiredRlimit = 50_000
)

Variables

View Source
var (

	// RootFlags has the flags that are common across all commands.
	RootFlags = flag.NewFlagSet("", flag.ContinueOnError)
)

Functions

func DataDir

func DataDir() string

DataDir returns the data directory iff one is set.

func DataDirOrPwd

func DataDirOrPwd() (string, error)

DataDirOrPwd returns the data directory iff one is set, pwd otherwise.

func EarlyLogAndExit

func EarlyLogAndExit(err error)

EarlyLogAndExit logs the error and exits.

Note: This routine should only be used prior to the logging system being initialized.

func ExportEntity

func ExportEntity(signerBackend, entityDir string) error

ExportEntity creates an empty entity from the public key of the signer generated with the specified backend, and writes it to a file in entityDir.

func GetInputReader

func GetInputReader(cmd *cobra.Command, cfg string) (io.ReadCloser, bool, error)

GetInputReader will open a file if the config string is set, and otherwise return os.Stdin.

func GetOutputWriter

func GetOutputWriter(cmd *cobra.Command, cfg string) (io.WriteCloser, bool, error)

GetOutputWriter will create a file if the config string is set, and otherwise return os.Stdout.

func GetUserConfirmation

func GetUserConfirmation(prompt string) bool

GetUserConfirmation displays the prompt, and scans the input for the user's confirmation, until the user either explicitly confirms or rejects the prompt.

Note: If standard input is not a tty, this will omit displaying the prompt, and assume the user entered yes.

func Init

func Init() error

Init initializes the common environment across all commands.

func InitConfig

func InitConfig()

InitConfig initializes the command configuration.

WARNING: This is exposed for the benefit of tests and the interface is not guaranteed to be stable.

func IsNodeCmd

func IsNodeCmd() bool

IsNodeCmd returns true iff the current command is the ekiden node.

func IsNotRootOrAllowed added in v0.2201.0

func IsNotRootOrAllowed() (canRun bool, isRoot bool)

IsNotRootOrAllowed returns if the current user is allowed to run a node, and if the effective user id is elevated or not.

func Isatty

func Isatty(fd uintptr) bool

Isatty returns true iff the provided file descriptor is a terminal.

func LoadEntitySigner added in v0.2100.0

func LoadEntitySigner() (*entity.Entity, signature.Signer, error)

LoadEntitySigner loads the entity and its signer.

func Logger

func Logger() *logging.Logger

Logger returns the command logger.

func PrettyJSONMarshal added in v0.2103.0

func PrettyJSONMarshal(v interface{}) ([]byte, error)

PrettyJSONMarshal returns pretty-printed JSON encoding of v.

func SetBasicVersionTemplate added in v0.2010.0

func SetBasicVersionTemplate(cmd *cobra.Command)

SetBasicVersionTemplate sets a basic custom version template for the given cobra command that shows the version of Oasis Core and the Go toolchain.

func SetIsNodeCmd

func SetIsNodeCmd(v bool)

SetIsNodeCmd sets the IsNodeCmd flag.

Types

This section is empty.

Directories

Path Synopsis
Package background implements utilities for managing background services.
Package background implements utilities for managing background services.
Package consensus contains common consensus-related flags.
Package consensus contains common consensus-related flags.
Package context implements common context helpers.
Package context implements common context helpers.
Package flags implements common flags used across multiple commands and backends.
Package flags implements common flags used across multiple commands and backends.
Package genesis implements common genesis document manipulation routines.
Package genesis implements common genesis document manipulation routines.
Package grpc implements common gRPC command-line flags.
Package grpc implements common gRPC command-line flags.
Package metrics implements a prometheus metrics service.
Package metrics implements a prometheus metrics service.
Package pprof implements a pprof profiling service.
Package pprof implements a pprof profiling service.
Package signer implements helpers for configuring the signer.
Package signer implements helpers for configuring the signer.

Jump to

Keyboard shortcuts

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