Documentation
¶
Overview ¶
Package options contains a set of common CLI options and helper functions to use them.
Index ¶
- Constants
- Variables
- 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 GetRPCWithInvoker(gctx context.Context, ctx *cli.Context, signers []transaction.Signer) (*rpcclient.Client, *invoker.Invoker, cli.ExitCoder)
- func GetTimeoutContext(ctx *cli.Context) (context.Context, func())
Constants ¶
const DefaultTimeout = 10 * time.Second
DefaultTimeout is the default timeout used for RPC requests.
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 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"}, cli.BoolFlag{Name: "mainnet, m", Usage: "use mainnet network configuration"}, cli.BoolFlag{Name: "testnet, t", Usage: "use testnet network configuration"}, 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).
Functions ¶
func GetInvoker ¶ added in v0.99.3
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.
Types ¶
This section is empty.