Documentation
¶
Index ¶
- Variables
- func GenerateKeyWorker(input *GenerateKeyInput) (string, error)
- func PopulateInput(state string, input string) (string, error)
- type Action
- type ActionType
- type Broadcast
- type GenerateKeyInput
- type Job
- type JobStatus
- type ReservedVariable
- type ReservedWorkflow
- type Scenario
- type Worker
- type WorkerHelper
- type Workflow
Constants ¶
This section is empty.
Variables ¶
var ( // ErrVariableNotFound is returned when a variable is not // present in a Job's state. ErrVariableNotFound = errors.New("variable not found") // ErrJobComplete is returned when there are no more scenarios // to process in a Job. ErrJobComplete = errors.New("job complete") // ErrInvalidInput is returned when the input for an Action // cannot be parsed. ErrInvalidInput = errors.New("invalid input") // ErrInvalidActionType is returned when an Action has an unsupported // type. ErrInvalidActionType = errors.New("invalid action type") // ErrUnableToCreateBroadcast is returned when it is not possible // to create a broadcast or check if a broadcast should be created // from a job. ErrUnableToCreateBroadcast = errors.New("unable to create broadcast") // ErrUnableToHandleBroadcast is returned if a Job cannot handle a // broadcast completion (usually because there is no broadcast to confirm). ErrUnableToHandleBroadcast = errors.New("unable to handle broadcast") // ErrActionFailed is returned when Action exeuction fails with a valid input. ErrActionFailed = errors.New("action execution failed") )
Functions ¶
func GenerateKeyWorker ¶
func GenerateKeyWorker(input *GenerateKeyInput) (string, error)
GenerateKeyWorker attempts to generate a key given a *GenerateKeyInput input.
Types ¶
type Action ¶
type Action struct { Input string Type ActionType OutputPath string }
Action is a step of computation that where the result is saved to OutputPath.
type ActionType ¶
type ActionType string
ActionType is a type of Action that can be processed.
const ( // GenerateKey creates a new *keys.KeyPair. GenerateKey ActionType = "generate_key" // SaveAddress saves a generated *keys.KeyPair // and address to key storage. SaveAddress ActionType = "save_address" // Derive calls `/construction/derive` with a *keys.PublicKey. Derive ActionType = "derive" // SetVariable allows for setting the value of any // variable (as opposed to calculating it using // other actions). SetVariable ActionType = "set_variable" // FindAccount finds some unlocked account that optionally // has a minimum balance of funds. FindAccount ActionType = "find_account" // FindCoin finds some coin above a certain amount. It is // possible to specify coins which should not be considered (by identifier). FindCoin ActionType = "find_coin" // PrintMessage prints some message to the terminal. This is // typically used for funding an account. PrintMessage ActionType = "print_message" // WaitForFunds halts execution until a specified // address has a minimum balance. WaitForFunds ActionType = "wait_for_funds" // Math is used to perform addition or subtraction of variables. It is // most commonly used to determine how much to send to a change output // on UTXO blockchains. Math ActionType = "math" // RandomString generates a string according to some provided regex. // It is used to generate account names for blockchains that require // on-chain origination. RandomString ActionType = "random_string" )
type Broadcast ¶
type Broadcast struct { Network *types.NetworkIdentifier Intent []*types.Operation Metadata map[string]interface{} ConfirmationDepth int64 }
Broadcast contains information needed to create and broadcast a transaction. Broadcast is returned from Job processing only IF a broadcast is required.
type GenerateKeyInput ¶
GenerateKeyInput is the input for GenerateKey.
type Job ¶
type Job struct { // Identifier is a UUID that is generated // when a Job is stored in JobStorage for the // first time. When executing the first scenario // in a Job, this will be empty. Identifier string State string Index int Status JobStatus // Workflow is the name of the workflow being executed. Workflow string // Scenarios are copied into each context in case // a configuration file changes that could corrupt // in-process flows. Scenarios []*Scenario }
Job is an instantion of a Workflow.
func (*Job) BroadcastComplete ¶
BroadcastComplete is called either after a broadcast has been confirmed at the provided confirmation depth or if it has failed for some reason.
type JobStatus ¶
type JobStatus string
JobStatus is status of a Job.
const ( // Ready means that a Job is ready to process. Ready JobStatus = "ready" // Broadcasting means that the intent of the last // scenario is broadcasting. Broadcasting JobStatus = "broadcasting" // Failed means that Broadcasting failed. Failed JobStatus = "failed" // Completed means that all scenarios were // completed successfully. Completed JobStatus = "completed" )
type ReservedVariable ¶
type ReservedVariable string
ReservedVariable is a reserved variable field in a Job's state.
const ( // Network is the *types.NetworkIdentifier to use // for broadcast. Network ReservedVariable = "network" // Operations are the []*types.Operation to use // as intent. Operations ReservedVariable = "operations" // PreprocessMetadata is the metadata to provide to /construction/preprocess. PreprocessMetadata ReservedVariable = "preprocess_metadata" // Transaction is the *types.Transaction confirmed // on-chain. Transaction ReservedVariable = "transaction" )
type ReservedWorkflow ¶
type ReservedWorkflow string
ReservedWorkflow is a Workflow reserved for special circumstances. All ReservedWorkflows must exist when running the constructor.
const ( // CreateAccount is where another account (already with funds) // creates a new account. It is possible to configure how many // accounts should be created. CreateAccount ReservedWorkflow = "create_account" // RequestFunds is where the user funds an account. This flow // is invoked when there are no pending broadcasts and it is not possible // to make progress on any Flows or start new ones. RequestFunds ReservedWorkflow = "request_funds" )
type Scenario ¶
type Scenario struct { Name string Actions []*Action // We set ConfirmationDepth on a per scenario basis because // certain transactions may only be considered complete // after some time (ex: staking transaction). ConfirmationDepth int64 }
Scenario is a collection of Actions with a specific confirmation depth.
There is a special variable you can set at the end of a scenario called "<scenario_name>.operations" to indicate that a transaction should be broadcast. It is also possible to specify the network where the transaction should be broadcast and the metadata to provide in a call to /construction/preprocess.
Once a scenario is broadcasted and confirmed, the transaction details are placed in a special variable called "transaction". This can be used in scenarios following the execution of this one.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker processes jobs.
func (*Worker) DeriveWorker ¶
func (w *Worker) DeriveWorker( ctx context.Context, input *types.ConstructionDeriveRequest, ) (string, error)
DeriveWorker attempts to derive an address given a *types.ConstructionDeriveRequest input.
type WorkerHelper ¶
type WorkerHelper interface { Derive( context.Context, *types.NetworkIdentifier, *types.PublicKey, map[string]interface{}, ) (string, map[string]interface{}, error) }
WorkerHelper is used by the worker to process Jobs.
type Workflow ¶
type Workflow struct { Name string // Concurrency is the number of workflows of a particular // kind to execute at once. For example, you may not want // to process concurrent workflows of some staking operations // that take days to play out. Concurrency int Scenarios []*Scenario }
Workflow is a collection of scenarios to run (i.e. transactions to broadcast) with some shared state.