Documentation ¶
Overview ¶
Package models contain the key job components used by the Chainlink application.
Common ¶
Common contains types and functions that are useful across the application. Particularly dealing with the URL field, dates, and time.
Eth ¶
Eth creates transactions and tracks transaction attempts on the Ethereum blockchain.
JobSpec ¶
A JobSpec is the largest unit of work that a Chainlink node can take on. It will have Initiators, which is how a JobRun is started from the job definition, and Tasks, which are the specific instructions for what work needs to be performed. The BridgeType is also located here, and is used to define the location (URL) of external adapters.
ORM ¶
The ORM is the wrapper around the database. It gives a limited set of functions to allow for safe storing and withdrawing of information.
Run ¶
A Run is the actual invocation of work being done on the Job and Task. This comprises of JobRuns and TaskRuns. A JobRun is like a workflow where the steps are the TaskRuns.
i.e. We have a Scheduler Initiator that creates a JobRun every monday based on a JobDefinition. And in turn, those JobRuns have TaskRuns based on the JobDefinition's TaskDefinitions.
V1 ¶
V1 contains the backwards compatibility for the Chainlink Ruby node. The Ruby node used a different JSON schema for Assignments, Subtasks, and Snapshots (now Specs, Tasks, and Runs). The functions in V1 allow for the node to accept and store V1-spec JSON with the same functionality of the V2 spec.
Index ¶
- Constants
- func NewDatabaseAccessError(msg string) error
- func NewValidationError(msg string, values ...interface{}) error
- type Assignment
- type AssignmentSpec
- type BlockHeader
- type BridgeRunResult
- type BridgeType
- type Cron
- type DatabaseAccessError
- type EIP55Address
- func (a EIP55Address) Address() common.Address
- func (a EIP55Address) Big() *big.Int
- func (a EIP55Address) Bytes() []byte
- func (a EIP55Address) Format(s fmt.State, c rune)
- func (a EIP55Address) Hash() common.Hash
- func (a EIP55Address) String() string
- func (a *EIP55Address) UnmarshalJSON(input []byte) error
- func (a *EIP55Address) UnmarshalText(input []byte) error
- type Encumbrance
- type EthSubscription
- type FunctionSelector
- type IndexableBlockNumber
- type Initiator
- type InitiatorParams
- type Int
- type JSON
- func (j JSON) Add(key string, val interface{}) (JSON, error)
- func (j JSON) Bytes() []byte
- func (j JSON) CBOR() ([]byte, error)
- func (j JSON) Delete(key string) (JSON, error)
- func (j JSON) Empty() bool
- func (j JSON) MarshalJSON() ([]byte, error)
- func (j JSON) Merge(j2 JSON) (JSON, error)
- func (j *JSON) UnmarshalJSON(b []byte) error
- type JSONAPIError
- type JSONAPIErrors
- type JobRun
- func (jr JobRun) ApplyResult(result RunResult) JobRun
- func (jr JobRun) ForLogger(kvs ...interface{}) []interface{}
- func (jr JobRun) GetID() string
- func (jr JobRun) GetName() string
- func (jr JobRun) MarkCompleted() JobRun
- func (jr JobRun) NextTaskRun() TaskRun
- func (jr JobRun) Runnable(currentHeight *IndexableBlockNumber, minConfs uint64) bool
- func (jr *JobRun) SetID(value string) error
- func (jr JobRun) UnfinishedTaskRuns() []TaskRun
- type JobSpec
- func (j JobSpec) Ended(t time.Time) bool
- func (j JobSpec) GetID() string
- func (j JobSpec) GetName() string
- func (j JobSpec) InitiatorsFor(types ...string) []Initiator
- func (j JobSpec) IsLogInitiated() bool
- func (j JobSpec) NewRun(i Initiator) JobRun
- func (j *JobSpec) SetID(value string) error
- func (j JobSpec) Started(t time.Time) bool
- func (j JobSpec) WebAuthorized() bool
- type JobSpecRequest
- type RunResult
- func (rr RunResult) Error() string
- func (rr RunResult) Get(path string) gjson.Result
- func (rr RunResult) GetError() error
- func (rr RunResult) HasError() bool
- func (rr RunResult) MarkPendingBridge() RunResult
- func (rr RunResult) MarkPendingConfirmations() RunResult
- func (rr RunResult) Merge(in RunResult) (RunResult, error)
- func (rr RunResult) Value() (string, error)
- func (rr RunResult) WithError(err error) RunResult
- func (rr RunResult) WithNull() RunResult
- func (rr RunResult) WithValue(val string) RunResult
- type RunStatus
- func (s RunStatus) CanStart() bool
- func (s RunStatus) Completed() bool
- func (s RunStatus) Errored() bool
- func (s RunStatus) Finished() bool
- func (s RunStatus) Pending() bool
- func (s RunStatus) PendingBridge() bool
- func (s RunStatus) PendingConfirmations() bool
- func (s RunStatus) PendingSleep() bool
- func (s RunStatus) Runnable() bool
- func (s RunStatus) Unstarted() bool
- type Schedule
- type ServiceAgreement
- type ServiceAgreementRequest
- type Session
- type SessionRequest
- type Signature
- func (s Signature) Big() *big.Int
- func (s Signature) Bytes() []byte
- func (s Signature) Format(state fmt.State, c rune)
- func (s Signature) Hex() string
- func (s Signature) MarshalJSON() ([]byte, error)
- func (s Signature) MarshalText() ([]byte, error)
- func (s *Signature) SetBytes(b []byte)
- func (s Signature) String() string
- func (s *Signature) UnmarshalJSON(input []byte) error
- func (s *Signature) UnmarshalText(input []byte) error
- type Signer
- type Snapshot
- type Subtask
- type TaskRun
- func (tr TaskRun) ApplyResult(result RunResult) TaskRun
- func (tr TaskRun) ForLogger(kvs ...interface{}) []interface{}
- func (tr TaskRun) MarkCompleted() TaskRun
- func (tr TaskRun) MarkPendingConfirmations() TaskRun
- func (tr TaskRun) MergeTaskParams(j JSON) (TaskRun, error)
- func (tr TaskRun) String() string
- type TaskSpec
- type TaskType
- type Time
- type Tx
- type TxAttempt
- type User
- type ValidationError
- type WebURL
- type WithdrawalRequest
Constants ¶
const ( // RunStatusUnstarted is the default state of any run status. RunStatusUnstarted = RunStatus("") // RunStatusInProgress is used for when a run is actively being executed. RunStatusInProgress = RunStatus("in_progress") // RunStatusPendingConfirmations is used for when a run is awaiting for block confirmations. RunStatusPendingConfirmations = RunStatus("pending_confirmations") // RunStatusPendingBridge is used for when a run is waiting on the completion // of another event. RunStatusPendingBridge = RunStatus("pending_bridge") // RunStatusPendingSleep is used for when a run is waiting on a sleep function to finish. RunStatusPendingSleep = RunStatus("pending_sleep") // RunStatusErrored is used for when a run has errored and will not complete. RunStatusErrored = RunStatus("errored") // RunStatusCompleted is used for when a run has successfully completed execution. RunStatusCompleted = RunStatus("completed") )
const ( // InitiatorRunLog for tasks in a job to watch an ethereum address // and expect a JSON payload from a log event. InitiatorRunLog = "runlog" // InitiatorCron for tasks in a job to be ran on a schedule. InitiatorCron = "cron" // InitiatorEthLog for tasks in a job to use the Ethereum blockchain. InitiatorEthLog = "ethlog" // InitiatorRunAt for tasks in a job to be ran once. InitiatorRunAt = "runat" // InitiatorWeb for tasks in a job making a web request. InitiatorWeb = "web" )
const FunctionSelectorLength = 4
FunctionSelectorLength should always be a length of 4 as a byte.
const ( // SignatureLength is the length of the signature in bytes: v = 1, r = 32, s // = 32; v + r + s = 65 SignatureLength = 65 )
Variables ¶
This section is empty.
Functions ¶
func NewDatabaseAccessError ¶
NewDatabaseAccessError returns a database access error.
func NewValidationError ¶
NewValidationError returns a validation error.
Types ¶
type Assignment ¶
type Assignment struct {
Subtasks []Subtask `json:"subtasks"`
}
Assignment contains all the subtasks to perform
type AssignmentSpec ¶
type AssignmentSpec struct { Assignment Assignment `json:"assignment"` Schedule Schedule `json:"schedule"` }
AssignmentSpec represents a specification of work to be given to an oracle this consists of an Assignment and a Schedule
func ConvertToAssignment ¶
func ConvertToAssignment(j JobSpec) (AssignmentSpec, error)
ConvertToAssignment converts JobSpec to AssignmentSpec
func (AssignmentSpec) ConvertToJobSpec ¶
func (s AssignmentSpec) ConvertToJobSpec() (JobSpec, error)
ConvertToJobSpec converts an AssignmentSpec to a JobSpec
type BlockHeader ¶
type BlockHeader struct { ParentHash common.Hash `json:"parentHash"` UncleHash common.Hash `json:"sha3Uncles"` Coinbase common.Address `json:"miner"` Root common.Hash `json:"stateRoot"` TxHash common.Hash `json:"transactionsRoot"` ReceiptHash common.Hash `json:"receiptsRoot"` Bloom types.Bloom `json:"logsBloom"` Difficulty hexutil.Big `json:"difficulty"` Number hexutil.Big `json:"number"` GasLimit hexutil.Uint64 `json:"gasLimit"` GasUsed hexutil.Uint64 `json:"gasUsed"` Time hexutil.Big `json:"timestamp"` Extra hexutil.Bytes `json:"extraData"` Nonce types.BlockNonce `json:"nonce"` GethHash common.Hash `json:"mixHash"` ParityHash common.Hash `json:"hash"` }
BlockHeader represents a block header in the Ethereum blockchain. Deliberately does not have required fields because some fields aren't present depending on the Ethereum node. i.e. Parity does not always send mixHash
func (BlockHeader) Hash ¶
func (h BlockHeader) Hash() common.Hash
Hash will return GethHash if it exists otherwise it returns the ParityHash
func (BlockHeader) ToIndexableBlockNumber ¶
func (h BlockHeader) ToIndexableBlockNumber() *IndexableBlockNumber
ToIndexableBlockNumber converts a given BlockHeader to an IndexableBlockNumber
type BridgeRunResult ¶
type BridgeRunResult struct { RunResult ExternalPending bool `json:"pending"` AccessToken string `json:"accessToken"` }
BridgeRunResult handles the parsing of RunResults from external adapters.
func (*BridgeRunResult) UnmarshalJSON ¶
func (brr *BridgeRunResult) UnmarshalJSON(input []byte) error
UnmarshalJSON parses the given input and updates the BridgeRunResult in the external adapter format.
type BridgeType ¶
type BridgeType struct { Name TaskType `json:"name" storm:"id,unique"` URL WebURL `json:"url"` Confirmations uint64 `json:"confirmations"` IncomingToken string `json:"incomingToken"` OutgoingToken string `json:"outgoingToken"` }
BridgeType is used for external adapters and has fields for the name of the adapter and its URL.
func (BridgeType) Authenticate ¶
func (bt BridgeType) Authenticate(token string) (bool, error)
Authenticate returns true if the passed token matches its IncomingToken, or returns false with an error.
func (BridgeType) GetID ¶
func (bt BridgeType) GetID() string
GetID returns the ID of this structure for jsonapi serialization.
func (BridgeType) GetName ¶
func (bt BridgeType) GetName() string
GetName returns the pluralized "type" of this structure for jsonapi serialization.
func (*BridgeType) SetID ¶
func (bt *BridgeType) SetID(value string) error
SetID is used to set the ID of this structure when deserializing from jsonapi documents.
type Cron ¶
type Cron string
Cron holds the string that will represent the spec of the cron-job. It uses 6 fields to represent the seconds (1), minutes (2), hours (3), day of the month (4), month (5), and day of the week (6).
func (*Cron) UnmarshalJSON ¶
UnmarshalJSON parses the raw spec stored in JSON-encoded data and stores it to the Cron string.
type DatabaseAccessError ¶
type DatabaseAccessError struct {
// contains filtered or unexported fields
}
DatabaseAccessError is an error that occurs during database access.
func (*DatabaseAccessError) Error ¶
func (e *DatabaseAccessError) Error() string
type EIP55Address ¶
type EIP55Address string
EIP55Address is a newtype for string which persists an ethereum address in its original string representation which includes a leading 0x, and EIP55 checksum which is represented by the case of digits A-F.
func NewEIP55Address ¶
func NewEIP55Address(s string) (EIP55Address, error)
NewEIP55Address creates an EIP55Address from a string, an error is returned if:
1) There is no leading 0x 2) The length is wrong 3) There are any non hexadecimal characters 4) The checksum fails
func (EIP55Address) Address ¶
func (a EIP55Address) Address() common.Address
Address returns EIP55Address as a go-ethereum Address type
func (EIP55Address) Format ¶
func (a EIP55Address) Format(s fmt.State, c rune)
Format implements fmt.Formatter
func (EIP55Address) String ¶
func (a EIP55Address) String() string
String implements the stringer interface and is used also by the logger.
func (*EIP55Address) UnmarshalJSON ¶
func (a *EIP55Address) UnmarshalJSON(input []byte) error
UnmarshalJSON parses a hash from a JSON string
func (*EIP55Address) UnmarshalText ¶
func (a *EIP55Address) UnmarshalText(input []byte) error
UnmarshalText parses a hash from plain text
type Encumbrance ¶
type Encumbrance struct { Payment *assets.Link `json:"payment"` Expiration uint64 `json:"expiration"` Oracles []EIP55Address `json:"oracles"` }
Encumbrance connects job specifications with on-chain encumbrances.
func (Encumbrance) ABI ¶
func (e Encumbrance) ABI() ([]byte, error)
ABI packs the encumberance as a byte array using the same technique as abi.encodePacked, meaning that addresses are padded with left 0s to match hashes in the oracle list
type EthSubscription ¶
type EthSubscription interface { Err() <-chan error Unsubscribe() }
EthSubscription should implement Err() <-chan error and Unsubscribe()
type FunctionSelector ¶
type FunctionSelector [FunctionSelectorLength]byte
FunctionSelector is the first four bytes of the call data for a function call and specifies the function to be called.
func BytesToFunctionSelector ¶
func BytesToFunctionSelector(b []byte) FunctionSelector
BytesToFunctionSelector converts the given bytes to a FunctionSelector.
func HexToFunctionSelector ¶
func HexToFunctionSelector(s string) FunctionSelector
HexToFunctionSelector converts the given string to a FunctionSelector.
func (*FunctionSelector) SetBytes ¶
func (f *FunctionSelector) SetBytes(b []byte)
SetBytes sets the FunctionSelector to that of the given bytes (will trim).
func (FunctionSelector) String ¶
func (f FunctionSelector) String() string
String returns the FunctionSelector as a string type.
func (*FunctionSelector) UnmarshalJSON ¶
func (f *FunctionSelector) UnmarshalJSON(input []byte) error
UnmarshalJSON parses the raw FunctionSelector and sets the FunctionSelector type to the given input.
func (FunctionSelector) WithoutPrefix ¶
func (f FunctionSelector) WithoutPrefix() string
WithoutPrefix returns the FunctionSelector as a string without the '0x' prefix.
type IndexableBlockNumber ¶
type IndexableBlockNumber struct { Number hexutil.Big `json:"number" storm:"id,unique"` Digits int `json:"digits" storm:"index"` Hash common.Hash `json:"hash"` }
IndexableBlockNumber represents a BlockNumber, BlockHash and the number of Digits in the BlockNumber
func NewIndexableBlockNumber ¶
func NewIndexableBlockNumber(bigint *big.Int, hash common.Hash) *IndexableBlockNumber
NewIndexableBlockNumber creates an IndexableBlockNumber given a BlockNumber and BlockHash
func (*IndexableBlockNumber) GreaterThan ¶
func (l *IndexableBlockNumber) GreaterThan(r *IndexableBlockNumber) bool
GreaterThan compares BlockNumbers and returns true if the reciever BlockNumber is greater than the supplied BlockNumber
func (*IndexableBlockNumber) NextInt ¶
func (l *IndexableBlockNumber) NextInt() *big.Int
NextInt returns the next BlockNumber as big.int
func (*IndexableBlockNumber) ToInt ¶
func (l *IndexableBlockNumber) ToInt() *big.Int
ToInt Coerces the value into *big.Int. Also handles nil *IndexableBlockNumber values to nil *big.Int.
type Initiator ¶
type Initiator struct { ID int `json:"id" storm:"id,increment"` JobID string `json:"jobId" storm:"index"` Type string `json:"type" storm:"index"` InitiatorParams `json:"params,omitempty"` }
Initiator could be thought of as a trigger, defines how a Job can be started, or rather, how a JobRun can be created from a Job. Initiators will have their own unique ID, but will be associated to a parent JobID.
func (Initiator) IsLogInitiated ¶
IsLogInitiated Returns true if triggered by event logs.
func (*Initiator) UnmarshalJSON ¶
UnmarshalJSON parses the raw initiator data and updates the initiator as long as the type is valid.
type InitiatorParams ¶
type InitiatorParams struct { Schedule Cron `json:"schedule,omitempty"` Time Time `json:"time,omitempty"` Ran bool `json:"ran,omitempty"` Address common.Address `json:"address,omitempty" storm:"index"` }
InitiatorParams is a collection of the possible parameters that different Initiators may require.
type Int ¶
Int stores large integers and can deserialize a variety of inputs.
func (*Int) UnmarshalJSON ¶
UnmarshalJSON implements encoding.JSONUnmarshaler.
func (*Int) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type JSON ¶
JSON stores the json types string, number, bool, and null. Arrays and Objects are returned as their raw json types.
func ParseCBOR ¶
ParseCBOR attempts to coerce the input byte array into valid CBOR and then coerces it into a JSON object.
func ParseJSON ¶
ParseJSON attempts to coerce the input byte array into valid JSON and parse it into a JSON object.
func (JSON) MarshalJSON ¶
MarshalJSON returns the JSON data if it already exists, returns an empty JSON object as bytes if not.
func (*JSON) UnmarshalJSON ¶
UnmarshalJSON parses the JSON bytes and stores in the *JSON pointer.
type JSONAPIError ¶
type JSONAPIError struct {
Detail string `json:"detail"`
}
JSONAPIError is an individual JSONAPI Error.
type JSONAPIErrors ¶
type JSONAPIErrors struct {
Errors []JSONAPIError `json:"errors"`
}
JSONAPIErrors holds errors conforming to the JSONAPI spec.
func NewJSONAPIErrors ¶
func NewJSONAPIErrors() *JSONAPIErrors
NewJSONAPIErrors creates an instance of JSONAPIErrors, with the intention of managing a collection of them.
func NewJSONAPIErrorsWith ¶
func NewJSONAPIErrorsWith(detail string) *JSONAPIErrors
NewJSONAPIErrorsWith creates an instance of JSONAPIErrors populated with this single detail.
func (*JSONAPIErrors) Add ¶
func (jae *JSONAPIErrors) Add(detail string)
Add adds a new error to JSONAPIErrors with the passed detail.
func (*JSONAPIErrors) CoerceEmptyToNil ¶
func (jae *JSONAPIErrors) CoerceEmptyToNil() error
CoerceEmptyToNil will return nil if JSONAPIErrors has no errors.
func (*JSONAPIErrors) Error ¶
func (jae *JSONAPIErrors) Error() string
Error collapses the collection of errors into a collection of comma separated strings.
func (*JSONAPIErrors) Merge ¶
func (jae *JSONAPIErrors) Merge(e error)
Merge combines the arrays of the passed error if it is of type JSONAPIErrors, otherwise simply adds a single error with the error string as detail.
type JobRun ¶
type JobRun struct { ID string `json:"id" storm:"id,unique"` JobID string `json:"jobId" storm:"index"` Result RunResult `json:"result" storm:"inline"` Status RunStatus `json:"status" storm:"index"` TaskRuns []TaskRun `json:"taskRuns" storm:"inline"` CreatedAt time.Time `json:"createdAt" storm:"index"` CompletedAt null.Time `json:"completedAt"` Initiator Initiator `json:"initiator"` CreationHeight *hexutil.Big `json:"creationHeight"` Overrides RunResult `json:"overrides"` }
JobRun tracks the status of a job by holding its TaskRuns and the Result of each Run.
func (JobRun) ApplyResult ¶
ApplyResult updates the JobRun's Result and Status
func (JobRun) ForLogger ¶
func (jr JobRun) ForLogger(kvs ...interface{}) []interface{}
ForLogger formats the JobRun for a common formatting in the log.
func (JobRun) GetName ¶
GetName returns the pluralized "type" of this structure for jsonapi serialization.
func (JobRun) MarkCompleted ¶
MarkCompleted sets the JobRun's status to completed and records the completed at time.
func (JobRun) NextTaskRun ¶
NextTaskRun returns the next immediate TaskRun in the list of unfinished TaskRuns.
func (JobRun) Runnable ¶
func (jr JobRun) Runnable(currentHeight *IndexableBlockNumber, minConfs uint64) bool
Runnable checks that the number of confirmations have passed since the job's creation height to determine if the JobRun can be started. Returns true for non-JobSubscriber (runlog & ethlog) initiators.
func (*JobRun) SetID ¶
SetID is used to set the ID of this structure when deserializing from jsonapi documents.
func (JobRun) UnfinishedTaskRuns ¶
UnfinishedTaskRuns returns a list of TaskRuns for a JobRun which are not Completed or Errored.
type JobSpec ¶
type JobSpec struct { ID string `json:"id" storm:"id,unique"` CreatedAt Time `json:"createdAt" storm:"index"` JobSpecRequest }
JobSpec is the definition for all the work to be carried out by the node for a given contract. It contains the Initiators, Tasks (which are the individual steps to be carried out), StartAt, EndAt, and CreatedAt fields.
func NewJob ¶
func NewJob() JobSpec
NewJob initializes a new job by generating a unique ID and setting the CreatedAt field to the time of invokation.
func (JobSpec) GetName ¶
GetName returns the pluralized "type" of this structure for jsonapi serialization.
func (JobSpec) InitiatorsFor ¶
InitiatorsFor returns an array of Initiators for the given list of Initiator types.
func (JobSpec) IsLogInitiated ¶
IsLogInitiated Returns true if any of the job's initiators are triggered by event logs.
func (JobSpec) NewRun ¶
NewRun initializes the job by creating the IDs for the job and all associated tasks, and setting the CreatedAt field.
func (*JobSpec) SetID ¶
SetID is used to set the ID of this structure when deserializing from jsonapi documents.
func (JobSpec) WebAuthorized ¶
WebAuthorized returns true if the "web" initiator is present.
type JobSpecRequest ¶
type JobSpecRequest struct { Initiators []Initiator `json:"initiators"` Tasks []TaskSpec `json:"tasks" storm:"inline"` StartAt null.Time `json:"startAt" storm:"index"` EndAt null.Time `json:"endAt" storm:"index"` }
JobSpecRequest represents a schema for the incoming job spec request as used by the API.
type RunResult ¶
type RunResult struct { JobRunID string `json:"jobRunId"` Data JSON `json:"data"` Status RunStatus `json:"status"` ErrorMessage null.String `json:"error"` Amount *assets.Link `json:"amount,omitempty"` }
RunResult keeps track of the outcome of a TaskRun or JobRun. It stores the Data and ErrorMessage, and contains a Pending field to track the status.
func (RunResult) MarkPendingBridge ¶
MarkPendingBridge returns a copy of RunResult but with status set to pending_bridge.
func (RunResult) MarkPendingConfirmations ¶
MarkPendingConfirmations returns a copy of RunResult but with status set to pending_confirmations.
func (RunResult) Merge ¶
Merge returns a copy which is the result of joining the input RunResult with the instance it is called on, preferring the RunResult values passed in, but using the existing values if the input RunResult values are of their respective zero value.
Returns an error if called on a RunResult that already has an error.
func (RunResult) WithError ¶
WithError returns a copy of the RunResult, setting the error field and setting the status to in progress.
type RunStatus ¶
type RunStatus string
RunStatus is a string that represents the run status
func (RunStatus) PendingBridge ¶
PendingBridge returns true if the status is pending_bridge.
func (RunStatus) PendingConfirmations ¶
PendingConfirmations returns true if the status is pending_confirmations.
func (RunStatus) PendingSleep ¶
PendingSleep returns true if the status is pending_sleep.
type Schedule ¶
type Schedule struct { EndAt Time `json:"endAt"` Hour null.String `json:"hour"` Minute null.String `json:"minute"` DayOfMonth null.String `json:"dayOfMonth"` MonthOfYear null.String `json:"monthOfYear"` DayOfWeek null.String `json:"dayOfWeek"` RunAt []Time `json:"runAt"` }
Schedule defines the frequency to run the Assignment Schedule uses standard cron syntax
type ServiceAgreement ¶
type ServiceAgreement struct { CreatedAt Time `json:"createdAt" storm:"index"` Encumbrance Encumbrance `json:"encumbrance" storm:"inline"` ID string `json:"id" storm:"id,unique"` JobSpecID string `json:"jobSpecID"` RequestBody string `json:"requestBody"` Signature Signature `json:"signature"` JobSpec JobSpec // JobSpec is used during the initial SA creation. }
ServiceAgreement connects job specifications with on-chain encumbrances.
func NewServiceAgreementFromRequest ¶
func NewServiceAgreementFromRequest(reader io.Reader, signer Signer) (ServiceAgreement, error)
NewServiceAgreementFromRequest builds a new ServiceAgreement.
func (ServiceAgreement) GetID ¶
func (sa ServiceAgreement) GetID() string
GetID returns the ID of this structure for jsonapi serialization.
func (ServiceAgreement) GetName ¶
func (sa ServiceAgreement) GetName() string
GetName returns the pluralized "type" of this structure for jsonapi serialization.
func (*ServiceAgreement) SetID ¶
func (sa *ServiceAgreement) SetID(value string) error
SetID is used to set the ID of this structure when deserializing from jsonapi documents.
type ServiceAgreementRequest ¶
type ServiceAgreementRequest struct { Payment *assets.Link `json:"payment"` Expiration uint64 `json:"expiration"` Oracles []EIP55Address `json:"oracles"` JobSpecRequest }
ServiceAgreementRequest represents a service agreement as requested over the wire.
type Session ¶
type Session struct { ID string `json:"id" storm:"id,unique"` LastUsed Time `json:"lastUsed" storm:"index"` }
Session holds the unique id for the authenticated session.
func NewSession ¶
func NewSession() Session
NewSession returns a session instance with ID set to a random ID and LastUsed to to now.
type SessionRequest ¶
SessionRequest encapsulates the fields needed to generate a new SessionID, including the hashed password.
type Signature ¶
type Signature [SignatureLength]byte
Signature is a byte array fixed to the size of a signature
func BytesToSignature ¶
BytesToSignature converts an arbitrary length byte array to a Signature
func NewSignature ¶
NewSignature returns a new Signature
func (Signature) MarshalJSON ¶
MarshalJSON prints the signature as a hexadecimal encoded string
func (Signature) MarshalText ¶
MarshalText encodes the signature in hexadecimal
func (*Signature) UnmarshalJSON ¶
UnmarshalJSON parses a signature from a JSON string
func (*Signature) UnmarshalText ¶
UnmarshalText parses the signature from a hexadecimal representation
type Snapshot ¶
type Snapshot struct { Details JSON `json:"details"` ID string `json:"xid"` Error null.String `json:"error"` Pending bool `json:"pending"` }
Snapshot captures the result of an individual subtask
func ConvertToSnapshot ¶
ConvertToSnapshot convert given RunResult to a Snapshot
type TaskRun ¶
type TaskRun struct { ID string `json:"id" storm:"id,unique"` Result RunResult `json:"result"` Status RunStatus `json:"status"` Task TaskSpec `json:"task"` }
TaskRun stores the Task and represents the status of the Task to be ran.
func (TaskRun) ApplyResult ¶
ApplyResult updates the TaskRun's Result and Status
func (TaskRun) ForLogger ¶
func (tr TaskRun) ForLogger(kvs ...interface{}) []interface{}
ForLogger formats the TaskRun info for a common formatting in the log.
func (TaskRun) MarkCompleted ¶
MarkCompleted marks the task's status as completed.
func (TaskRun) MarkPendingConfirmations ¶
MarkPendingConfirmations marks the task's status as blocked.
func (TaskRun) MergeTaskParams ¶
MergeTaskParams merges the existing parameters on a TaskRun with the given JSON.
type TaskSpec ¶
type TaskSpec struct { Type TaskType `json:"type" storm:"index"` Confirmations uint64 `json:"confirmations"` Params JSON `json:"params"` }
TaskSpec is the definition of work to be carried out. The Type will be an adapter, and the Params will contain any additional information that adapter would need to operate.
type TaskType ¶
type TaskType string
TaskType defines what Adapter a TaskSpec will use.
func MustNewTaskType ¶
MustNewTaskType instantiates a new TaskType, and panics if a bad input is provided.
func NewTaskType ¶
NewTaskType returns a formatted Task type.
func (TaskType) MarshalJSON ¶
MarshalJSON converts a TaskType to a JSON byte slice.
func (*TaskType) UnmarshalJSON ¶
UnmarshalJSON converts a bytes slice of JSON to a TaskType.
type Time ¶
Time holds a common field for time.
func (Time) DurationFromNow ¶
DurationFromNow returns the amount of time since the Time field was last updated.
func (Time) HumanString ¶
HumanString formats and returns the time in RFC 3339 standard.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON parses the raw time stored in JSON-encoded data and stores it to the Time field.
type Tx ¶
type Tx struct { ID uint64 `storm:"id,increment,index"` From common.Address `storm:"index"` To common.Address Data []byte Nonce uint64 `storm:"index"` Value *big.Int GasLimit uint64 TxAttempt }
Tx contains fields necessary for an Ethereum transaction with an additional field for the TxAttempt.
type TxAttempt ¶
type TxAttempt struct { Hash common.Hash `storm:"id,unique"` TxID uint64 `storm:"index"` GasPrice *big.Int Confirmed bool Hex string SentAt uint64 }
TxAttempt is used for keeping track of transactions that have been written to the Ethereum blockchain. This makes it so that if the network is busy, a transaction can be resubmitted with a higher GasPrice.
type User ¶
type User struct { Email string `json:"email" storm:"id,unique"` HashedPassword string `json:"hashedPassword"` CreatedAt Time `json:"createdAt" storm:"index"` }
User holds the credentials for API user.
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
ValidationError is an error that occurs during validation.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type WebURL ¶
WebURL contains the URL of the endpoint.
func (*WebURL) MarshalJSON ¶
MarshalJSON returns the JSON-encoded string of the given data.
func (*WebURL) String ¶
String delegates to the wrapped URL struct or an empty string when it is nil
func (*WebURL) UnmarshalJSON ¶
UnmarshalJSON parses the raw URL stored in JSON-encoded data to a URL structure and sets it to the URL field.