Documentation ¶
Overview ¶
Package options contains a set of common CLI options and helper functions to use them.
Index ¶
- Constants
- Variables
- func GetAccFromContext(ctx *cli.Context) (*wallet.Account, *wallet.Wallet, error)
- func GetConfigFromContext(ctx *cli.Context) (config.Config, error)
- func GetInvoker(c *rpcclient.Client, ctx *cli.Context, signers []transaction.Signer) (*invoker.Invoker, cli.ExitCoder)
- func GetNetwork(ctx *cli.Context) netmode.Magic
- func GetRPCClient(gctx context.Context, ctx *cli.Context) (*rpcclient.Client, cli.ExitCoder)
- func GetRPCWithActor(gctx context.Context, ctx *cli.Context, signers []actor.SignerAccount) (*rpcclient.Client, *actor.Actor, cli.ExitCoder)
- func GetRPCWithInvoker(gctx context.Context, ctx *cli.Context, signers []transaction.Signer) (*rpcclient.Client, *invoker.Invoker, cli.ExitCoder)
- func GetTimeoutContext(ctx *cli.Context) (context.Context, func())
- func GetUnlockedAccount(wall *wallet.Wallet, addr util.Uint160, pass *string) (*wallet.Account, error)
- func HandleLoggingParams(debug bool, cfg config.ApplicationConfiguration) (*zap.Logger, *zap.AtomicLevel, func() error, error)
- func NewFilteringCore(next zapcore.Core, filter FilterFunc) zapcore.Core
- func ReadWalletConfig(configPath string) (*config.Wallet, error)
- type FilterFunc
- type FilteringCore
Constants ¶
const ( // DefaultTimeout is the default timeout used for RPC requests. DefaultTimeout = 10 * time.Second // DefaultAwaitableTimeout is the default timeout used for RPC requests that // require transaction awaiting. It is set to the approximate time of three // Neo N3 mainnet blocks accepting. DefaultAwaitableTimeout = 3 * 15 * time.Second )
const RPCEndpointFlag = "rpc-endpoint"
RPCEndpointFlag is a long flag name for an RPC endpoint. It can be used to check for flag presence in the context.
Variables ¶
var Config = cli.StringFlag{
Name: "config-path",
Usage: "path to directory with per-network configuration files (may be overridden by --config-file option for the configuration file)",
}
Config is a flag for commands that use node configuration.
var ConfigFile = cli.StringFlag{
Name: "config-file",
Usage: "path to the node configuration file (overrides --config-path option)",
}
ConfigFile is a flag for commands that use node configuration and provide path to the specific config file instead of config path.
var Debug = cli.BoolFlag{
Name: "debug, d",
Usage: "enable debug logging (LOTS of output, overrides configuration)",
}
Debug is a flag for commands that allow node in debug mode usage.
var Historic = cli.StringFlag{
Name: "historic",
Usage: "Use historic state (height, block hash or state root hash)",
}
Historic is a flag for commands that can perform historic invocations.
var Network = []cli.Flag{ cli.BoolFlag{Name: "privnet, p", Usage: "use private network configuration (if --config-file option is not specified)"}, cli.BoolFlag{Name: "mainnet, m", Usage: "use mainnet network configuration (if --config-file option is not specified)"}, cli.BoolFlag{Name: "testnet, t", Usage: "use testnet network configuration (if --config-file option is not specified)"}, cli.BoolFlag{Name: "unittest", Hidden: true}, }
Network is a set of flags for choosing the network to operate on (privnet/mainnet/testnet).
var RPC = []cli.Flag{ cli.StringFlag{ Name: RPCEndpointFlag + ", r", Usage: "RPC node address", }, cli.DurationFlag{ Name: "timeout, s", Value: DefaultTimeout, Usage: "Timeout for the operation", }, }
RPC is a set of flags used for RPC connections (endpoint and timeout).
var RelativePath = cli.StringFlag{
Name: "relative-path",
Usage: "a prefix to all relative paths in the node configuration file",
}
RelativePath is a flag for commands that use node configuration and provide a prefix to all relative paths in config files.
var Wallet = []cli.Flag{cli.StringFlag{ Name: "wallet, w", Usage: "wallet to use to get the key for transaction signing; conflicts with --wallet-config flag", }, cli.StringFlag{ Name: "wallet-config", Usage: "path to wallet config to use to get the key for transaction signing; conflicts with --wallet flag"}, }
Wallet is a set of flags used for wallet operations.
Functions ¶
func GetAccFromContext ¶
GetAccFromContext returns account and wallet from context. If address is not set, default address is used.
func GetConfigFromContext ¶
GetConfigFromContext looks at the path and the mode flags in the given config and returns an appropriate config.
func GetInvoker ¶
func GetInvoker(c *rpcclient.Client, ctx *cli.Context, signers []transaction.Signer) (*invoker.Invoker, cli.ExitCoder)
GetInvoker returns an invoker using the given RPC client, context and signers. It parses "--historic" parameter to adjust it.
func GetNetwork ¶
GetNetwork examines Context's flags and returns the appropriate network. It defaults to PrivNet if no flags are given.
func GetRPCClient ¶
GetRPCClient returns an RPC client instance for the given Context.
func GetRPCWithActor ¶
func GetRPCWithActor(gctx context.Context, ctx *cli.Context, signers []actor.SignerAccount) (*rpcclient.Client, *actor.Actor, cli.ExitCoder)
GetRPCWithActor returns an RPC client instance and Actor instance for the given context.
func GetRPCWithInvoker ¶
func GetRPCWithInvoker(gctx context.Context, ctx *cli.Context, signers []transaction.Signer) (*rpcclient.Client, *invoker.Invoker, cli.ExitCoder)
GetRPCWithInvoker combines GetRPCClient with GetInvoker for cases where it's appropriate to do so.
func GetTimeoutContext ¶
GetTimeoutContext returns a context.Context with the default or a user-set timeout.
func GetUnlockedAccount ¶
func GetUnlockedAccount(wall *wallet.Wallet, addr util.Uint160, pass *string) (*wallet.Account, error)
GetUnlockedAccount returns account from wallet, address and uses pass to unlock specified account if given. If the password is not given, then it is requested from user.
func HandleLoggingParams ¶
func HandleLoggingParams(debug bool, cfg config.ApplicationConfiguration) (*zap.Logger, *zap.AtomicLevel, func() error, error)
HandleLoggingParams reads logging parameters. If a user selected debug level -- function enables it. If logPath is configured -- function creates a dir and a file for logging. If logPath is configured on Windows -- function returns closer to be able to close sink for the opened log output file.
func NewFilteringCore ¶
func NewFilteringCore(next zapcore.Core, filter FilterFunc) zapcore.Core
NewFilteringCore returns a core middleware that uses the given filter function to decide whether to log this message or not.
Types ¶
type FilterFunc ¶
FilterFunc is the filter function that is called to check whether the given entry together with the associated fields is to be written to a core or not.
type FilteringCore ¶
FilteringCore is custom implementation of zapcore.Core that allows to filter log entries using custom filtering function.
func (*FilteringCore) Check ¶
func (c *FilteringCore) Check(e zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry
Check implements zapcore.Core interface and performs log entries filtering.