chainlink: github.com/smartcontractkit/chainlink/core/store/models Index | Files | Directories

package models

import "github.com/smartcontractkit/chainlink/core/store/models"

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.

Index

Package Files

address.go bridge_run_result.go bridge_type.go bulk.go cbor.go common.go doc.go errors.go eth.go external_initiator.go id.go job_run.go job_spec.go key.go log_events.go parse_randomness_request.go randomness_log_event.go run_input.go run_output.go service_agreement.go signature.go sync_events.go user.go

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")
    // RunStatusPendingConnection states that the run is waiting on a connection to the block chain.
    RunStatusPendingConnection = RunStatus("pending_connection")
    // 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")
    // RunStatusCancelled is used to indicate a run is no longer desired.
    RunStatusCancelled = RunStatus("cancelled")
)
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"
    // InitiatorServiceAgreementExecutionLog for tasks in a job to watch a
    // Solidity Coordinator contract and expect a payload from a log event.
    InitiatorServiceAgreementExecutionLog = "execagreement"
    // InitiatorExternal for tasks in a job to be trigger by an external party.
    InitiatorExternal = "external"
    // InitiatorFluxMonitor for tasks in a job to be run on price deviation
    // or request for a new round of prices.
    InitiatorFluxMonitor = "fluxmonitor"
    // InitiatorRandomnessLog for tasks from a VRF specific contract
    InitiatorRandomnessLog = "randomnesslog"
)

Types of Initiators (see Initiator struct just below.)

const (
    RequestLogTopicSignature = iota
    RequestLogTopicJobID
    RequestLogTopicRequester
    RequestLogTopicPayment
)

Descriptive indices of a RunLog's Topic array

const (
    // SignatureLength is the length of the signature in bytes: v = 1, r = 32, s
    // = 32; v + r + s = 65
    SignatureLength = 65
)

Variables

var (
    // RunLogTopic0original was the original topic to filter for Oracle.sol RunRequest events.
    RunLogTopic0original = utils.MustHash("RunRequest(bytes32,address,uint256,uint256,uint256,bytes)")
    // RunLogTopic20190123withFullfillmentParams was the new RunRequest filter topic as of 2019-01-23,
    // when callback address, callback function, and expiration were added to the data payload.
    RunLogTopic20190123withFullfillmentParams = utils.MustHash("RunRequest(bytes32,address,uint256,uint256,uint256,address,bytes4,uint256,bytes)")
    // RunLogTopic20190207withoutIndexes was the new RunRequest filter topic as of 2019-01-28,
    // after renaming Solidity variables, moving data version, and removing the cast of requestId to uint256
    RunLogTopic20190207withoutIndexes = utils.MustHash("OracleRequest(bytes32,address,bytes32,uint256,address,bytes4,uint256,uint256,bytes)")
    // ServiceAgreementExecutionLogTopic is the signature for the
    // Coordinator.RunRequest(...) events which Chainlink nodes watch for. See
    // ../../../evm-contracts/src/v0.5/dev/Coordinator.sol#RunRequest
    ServiceAgreementExecutionLogTopic = utils.MustHash("ServiceAgreementExecution(bytes32,address,uint256,uint256,uint256,bytes)")
    // RandomnessRequestLogTopic is the signature for the event log
    // VRFCoordinator.RandomnessRequest.
    RandomnessRequestLogTopic = vrf.RandomnessRequestLogTopic()
    // OracleFullfillmentFunctionID0original is the original function selector for fulfilling Ethereum requests.
    OracleFullfillmentFunctionID0original = utils.MustHash("fulfillData(uint256,bytes32)").Hex()[:10]
    // OracleFulfillmentFunctionID20190123withFulfillmentParams is the function selector for fulfilling Ethereum requests,
    // as updated on 2019-01-23, accepting all fulfillment callback parameters.
    OracleFulfillmentFunctionID20190123withFulfillmentParams = utils.MustHash("fulfillData(uint256,uint256,address,bytes4,uint256,bytes32)").Hex()[:10]
    // OracleFulfillmentFunctionID20190128withoutCast is the function selector for fulfilling Ethereum requests,
    // as updated on 2019-01-28, removing the cast to uint256 for the requestId.
    OracleFulfillmentFunctionID20190128withoutCast = utils.MustHash("fulfillOracleRequest(bytes32,uint256,address,bytes4,uint256,bytes32)").Hex()[:10]
)
var FluxMonitorDefaultInitiatorParams = InitiatorParams{
    PollingInterval: Duration(time.Minute),
}

FluxMonitorDefaultInitiatorParams are the default parameters for Flux Monitor Job Specs.

var LogBasedChainlinkJobInitiators = []string{InitiatorRunLog, InitiatorEthLog,
    InitiatorServiceAgreementExecutionLog, InitiatorRandomnessLog}

LogBasedChainlinkJobInitiators are initiators which kick off a user-specified chainlink job when an appropriate ethereum log is received. (InitiatorFluxMonitor kicks off work, but not a user-specified job.)

var TopicsForInitiatorsWhichRequireJobSpecIDTopic = map[string][]common.Hash{
    InitiatorRunLog: {RunLogTopic20190207withoutIndexes,
        RunLogTopic20190123withFullfillmentParams, RunLogTopic0original},
    InitiatorServiceAgreementExecutionLog: {ServiceAgreementExecutionLogTopic},
    InitiatorRandomnessLog:                {RandomnessRequestLogTopic},
}

topicsForInitiatorsWhichRequireJobSpecTopic are the log topics which kick off a user job with the given type of initiator. If chainlink has any jobs with these initiators, it subscribes on startup to logs which match both these topics and some representation of the job spec ID.

func AuthenticateBridgeType Uses

func AuthenticateBridgeType(bt *BridgeType, token string) (bool, error)

AuthenticateBridgeType returns true if the passed token matches its IncomingToken, or returns false with an error.

func AuthenticateExternalInitiator Uses

func AuthenticateExternalInitiator(eia *auth.Token, ea *ExternalInitiator) (bool, error)

AuthenticateExternalInitiator compares an auth against an initiator and returns true if the password hashes match

func AuthenticateUserByToken Uses

func AuthenticateUserByToken(token *auth.Token, user *User) (bool, error)

AuthenticateUserByToken returns true on successful authentication of the user against the given Authentication Token.

func FilterQueryFactory Uses

func FilterQueryFactory(i Initiator, from *big.Int) (q ethereum.FilterQuery, err error)

FilterQueryFactory returns the ethereum FilterQuery for this initiator.

func IDToHexTopic Uses

func IDToHexTopic(id *ID) common.Hash

IDToHexTopic encodes the string representation of the ID

func IDToTopic Uses

func IDToTopic(id *ID) common.Hash

IDToTopic encodes the bytes representation of the ID padded to fit into a bytes32

func JobSpecIDTopics Uses

func JobSpecIDTopics(jsID *ID) []common.Hash

jobSpecIDTopics lists the ways jsID could be represented as a log topic. This allows log subscriptions to respond to all possible representations.

func NewBridgeType Uses

func NewBridgeType(btr *BridgeTypeRequest) (*BridgeTypeAuthentication,
    *BridgeType, error)

NewBridgeType returns a bridge bridge type authentication (with plaintext password) and a bridge type (with hashed password, for persisting)

func NewDatabaseAccessError Uses

func NewDatabaseAccessError(msg string) error

NewDatabaseAccessError returns a database access error.

func NewValidationError Uses

func NewValidationError(msg string, values ...interface{}) error

NewValidationError returns a validation error.

func ValidateBulkDeleteRunRequest Uses

func ValidateBulkDeleteRunRequest(request *BulkDeleteRunRequest) error

ValidateBulkDeleteRunRequest returns a task from a request to make a task

type AddressCollection Uses

type AddressCollection []common.Address

AddressCollection is an array of common.Address serializable to and from a database.

func (*AddressCollection) Scan Uses

func (r *AddressCollection) Scan(value interface{}) error

Scan parses the database value as a string.

func (AddressCollection) ToStrings Uses

func (r AddressCollection) ToStrings() []string

ToStrings returns this address collection as an array of strings.

func (AddressCollection) Value Uses

func (r AddressCollection) Value() (driver.Value, error)

Value returns the string value to be written to the database.

type AnyTime Uses

type AnyTime struct {
    time.Time
    Valid bool
}

AnyTime holds a common field for time, and serializes it as a json number.

func NewAnyTime Uses

func NewAnyTime(t time.Time) AnyTime

NewAnyTime creates a new Time.

func (AnyTime) MarshalJSON Uses

func (t AnyTime) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode null if this time is null.

func (AnyTime) MarshalText Uses

func (t AnyTime) MarshalText() ([]byte, error)

MarshalText returns null if not set, or the time.

func (*AnyTime) Scan Uses

func (t *AnyTime) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (*AnyTime) UnmarshalJSON Uses

func (t *AnyTime) UnmarshalJSON(b []byte) error

UnmarshalJSON parses the raw time stored in JSON-encoded data and stores it to the Time field.

func (*AnyTime) UnmarshalText Uses

func (t *AnyTime) UnmarshalText(text []byte) error

UnmarshalText parses null or a valid time.

func (AnyTime) Value Uses

func (t AnyTime) Value() (driver.Value, error)

Value returns this instance serialized for database storage.

type BridgeRunResult Uses

type BridgeRunResult struct {
    Data            JSON        `json:"data"`
    Status          RunStatus   `json:"status"`
    ErrorMessage    null.String `json:"error"`
    ExternalPending bool        `json:"pending"`
    AccessToken     string      `json:"accessToken"`
}

BridgeRunResult handles the parsing of RunResults from external adapters.

func (BridgeRunResult) GetError Uses

func (brr BridgeRunResult) GetError() error

GetError returns the error of a BridgeRunResult if it is present.

func (BridgeRunResult) HasError Uses

func (brr BridgeRunResult) HasError() bool

HasError returns true if the status is errored or the error message is set

func (*BridgeRunResult) UnmarshalJSON Uses

func (brr *BridgeRunResult) UnmarshalJSON(input []byte) error

UnmarshalJSON parses the given input and updates the BridgeRunResult in the external adapter format.

type BridgeType Uses

type BridgeType struct {
    Name                   TaskType     `json:"name" gorm:"primary_key"`
    URL                    WebURL       `json:"url"`
    Confirmations          uint32       `json:"confirmations"`
    IncomingTokenHash      string       `json:"-"`
    Salt                   string       `json:"-"`
    OutgoingToken          string       `json:"outgoingToken"`
    MinimumContractPayment *assets.Link `json:"minimumContractPayment" gorm:"type:varchar(255)"`
}

BridgeType is used for external adapters and has fields for the name of the adapter and its URL.

func (BridgeType) GetID Uses

func (bt BridgeType) GetID() string

GetID returns the ID of this structure for jsonapi serialization.

func (BridgeType) GetName Uses

func (bt BridgeType) GetName() string

GetName returns the pluralized "type" of this structure for jsonapi serialization.

func (*BridgeType) SetID Uses

func (bt *BridgeType) SetID(value string) error

SetID is used to set the ID of this structure when deserializing from jsonapi documents.

type BridgeTypeAuthentication Uses

type BridgeTypeAuthentication struct {
    Name                   TaskType     `json:"name"`
    URL                    WebURL       `json:"url"`
    Confirmations          uint32       `json:"confirmations"`
    IncomingToken          string       `json:"incomingToken"`
    OutgoingToken          string       `json:"outgoingToken"`
    MinimumContractPayment *assets.Link `json:"minimumContractPayment"`
}

BridgeTypeAuthentication is the record returned in response to a request to create a BridgeType

func (BridgeTypeAuthentication) GetID Uses

func (bt BridgeTypeAuthentication) GetID() string

GetID returns the ID of this structure for jsonapi serialization.

func (BridgeTypeAuthentication) GetName Uses

func (bt BridgeTypeAuthentication) GetName() string

GetName returns the pluralized "type" of this structure for jsonapi serialization.

func (*BridgeTypeAuthentication) SetID Uses

func (bt *BridgeTypeAuthentication) SetID(value string) error

SetID is used to set the ID of this structure when deserializing from jsonapi documents.

type BridgeTypeRequest Uses

type BridgeTypeRequest struct {
    Name                   TaskType     `json:"name"`
    URL                    WebURL       `json:"url"`
    Confirmations          uint32       `json:"confirmations"`
    MinimumContractPayment *assets.Link `json:"minimumContractPayment"`
}

BridgeTypeRequest is the incoming record used to create a BridgeType

func (BridgeTypeRequest) GetID Uses

func (bt BridgeTypeRequest) GetID() string

GetID returns the ID of this structure for jsonapi serialization.

func (BridgeTypeRequest) GetName Uses

func (bt BridgeTypeRequest) GetName() string

GetName returns the pluralized "type" of this structure for jsonapi serialization.

func (*BridgeTypeRequest) SetID Uses

func (bt *BridgeTypeRequest) SetID(value string) error

SetID is used to set the ID of this structure when deserializing from jsonapi documents.

type BulkDeleteRunRequest Uses

type BulkDeleteRunRequest struct {
    ID            uint                `gorm:"primary_key"`
    Status        RunStatusCollection `json:"status" gorm:"type:text"`
    UpdatedBefore time.Time           `json:"updatedBefore"`
}

BulkDeleteRunRequest describes the query for deletion of runs

type ChangeAuthTokenRequest Uses

type ChangeAuthTokenRequest struct {
    Password string `json:"password"`
}

Changeauth.TokenRequest is sent when updating a User's authentication token.

type ChangePasswordRequest Uses

type ChangePasswordRequest struct {
    OldPassword string `json:"oldPassword"`
    NewPassword string `json:"newPassword"`
}

ChangePasswordRequest sets a new password for the current Session's User.

type Configuration Uses

type Configuration struct {
    gorm.Model
    Name  string `gorm:"not null;unique;index"`
    Value string `gorm:"not null"`
}

Configuration stores key value pairs for overriding global configuration

type CreateKeyRequest Uses

type CreateKeyRequest struct {
    CurrentPassword string `json:"current_password"`
}

CreateKeyRequest represents a request to add an ethereum key.

type Cron Uses

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) String Uses

func (c Cron) String() string

String returns the current Cron spec string.

func (*Cron) UnmarshalJSON Uses

func (c *Cron) UnmarshalJSON(b []byte) error

UnmarshalJSON parses the raw spec stored in JSON-encoded data and stores it to the Cron string.

type DatabaseAccessError Uses

type DatabaseAccessError struct {
    // contains filtered or unexported fields
}

DatabaseAccessError is an error that occurs during database access.

func (*DatabaseAccessError) Error Uses

func (e *DatabaseAccessError) Error() string

type Duration Uses

type Duration time.Duration

Duration is a time duration.

func (Duration) Duration Uses

func (d Duration) Duration() time.Duration

Duration returns the value as the standard time.Duration value.

func (Duration) MarshalJSON Uses

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Duration) String Uses

func (d Duration) String() string

String returns a string representing the duration in the form "72h3m0.5s". Leading zero units are omitted. As a special case, durations less than one second format use a smaller unit (milli-, micro-, or nanoseconds) to ensure that the leading digit is non-zero. The zero duration formats as 0s.

func (*Duration) UnmarshalJSON Uses

func (d *Duration) UnmarshalJSON(input []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type EIP55Address Uses

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 Uses

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 Uses

func (a EIP55Address) Address() common.Address

Address returns EIP55Address as a go-ethereum Address type

func (EIP55Address) Big Uses

func (a EIP55Address) Big() *big.Int

Big returns a big.Int representation

func (EIP55Address) Bytes Uses

func (a EIP55Address) Bytes() []byte

Bytes returns the raw bytes

func (EIP55Address) Format Uses

func (a EIP55Address) Format(s fmt.State, c rune)

Format implements fmt.Formatter

func (EIP55Address) Hash Uses

func (a EIP55Address) Hash() common.Hash

Hash returns the Hash

func (*EIP55Address) Scan Uses

func (a *EIP55Address) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (EIP55Address) String Uses

func (a EIP55Address) String() string

String implements the stringer interface and is used also by the logger.

func (*EIP55Address) UnmarshalJSON Uses

func (a *EIP55Address) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a hash from a JSON string

func (*EIP55Address) UnmarshalText Uses

func (a *EIP55Address) UnmarshalText(input []byte) error

UnmarshalText parses a hash from plain text

func (EIP55Address) Value Uses

func (a EIP55Address) Value() (driver.Value, error)

Value returns this instance serialized for database storage.

type EIP55AddressCollection Uses

type EIP55AddressCollection []EIP55Address

EIP55AddressCollection is an array of EIP55Addresses.

func (*EIP55AddressCollection) Scan Uses

func (c *EIP55AddressCollection) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (EIP55AddressCollection) Value Uses

func (c EIP55AddressCollection) Value() (driver.Value, error)

Value returns this instance serialized for database storage.

type EncryptedSecretVRFKey Uses

type EncryptedSecretVRFKey = vrfkey.EncryptedSecretKey

type Encumbrance Uses

type Encumbrance struct {
    // Corresponds to requestDigest in solidity ServiceAgreement struct
    ID  uint `json:"-" gorm:"primary_key;auto_increment"`
    // Price to request a report based on this agreement
    Payment *assets.Link `json:"payment,omitempty" gorm:"type:varchar(255)"`
    // Expiration is the amount of time an oracle has to answer a request
    Expiration uint64 `json:"expiration"`
    // Agreement is valid until this time
    EndAt AnyTime `json:"endAt"`
    // Addresses of oracles committed to this agreement
    Oracles EIP55AddressCollection `json:"oracles" gorm:"type:text"`
    // Address of aggregator contract
    Aggregator EIP55Address `json:"aggregator" gorm:"not null"`
    // selector for initialization method on aggregator contract
    AggInitiateJobSelector eth.FunctionSelector `json:"aggInitiateJobSelector" gorm:"not null"`
    // selector for fulfillment (oracle reporting) method on aggregator contract
    AggFulfillSelector eth.FunctionSelector `json:"aggFulfillSelector" gorm:"not null"`
}

Encumbrance connects job specifications with on-chain encumbrances.

func (Encumbrance) ABI Uses

func (e Encumbrance) ABI(digest common.Hash) ([]byte, error)

ABI packs the encumberance as a byte array using the same rules as the abi.encodePacked in Coordinator#getId.

Used only for constructing a stable hash which will be signed by all oracles, so it does not have to be easily parsed or unambiguous (e.g., re-ordering Oracles will result in different output.) It just has to be an injective function.

type EthLogEvent Uses

type EthLogEvent struct {
    InitiatorLogEvent
}

EthLogEvent provides functionality specific to a log event emitted for an eth log initiator.

type ExternalInitiator Uses

type ExternalInitiator struct {
    Name           string  `gorm:"not null;unique"`
    URL            *WebURL `gorm:"url,omitempty"`
    AccessKey      string  `gorm:"not null"`
    Salt           string  `gorm:"not null"`
    HashedSecret   string  `gorm:"not null"`
    OutgoingSecret string  `gorm:"not null"`
    OutgoingToken  string  `gorm:"not null"`

    CreatedAt time.Time
    UpdatedAt time.Time
}

ExternalInitiator represents a user that can initiate runs remotely

func NewExternalInitiator Uses

func NewExternalInitiator(
    eia *auth.Token,
    eir *ExternalInitiatorRequest,
) (*ExternalInitiator, error)

NewExternalInitiator generates an ExternalInitiator from an auth.Token, hashing the password for storage

type ExternalInitiatorRequest Uses

type ExternalInitiatorRequest struct {
    Name string  `json:"name"`
    URL  *WebURL `json:"url,omitempty"`
}

ExternalInitiatorRequest is the incoming record used to create an ExternalInitiator.

type Feeds Uses

type Feeds = JSON

Feeds holds the json of the feeds parameter in the job spec. It is an array of URL strings and/or objects containing the names of bridges

type Head struct {
    ID     uint64      `gorm:"primary_key;auto_increment"`
    Hash   common.Hash `gorm:"not null"`
    Number int64       `gorm:"index;not null"`
}

Head represents a BlockNumber, BlockHash.

func NewHead Uses

func NewHead(bigint *big.Int, hash common.Hash) *Head

NewHead returns a Head instance with a BlockNumber and BlockHash.

func (Head) AfterCreate Uses

func (h Head) AfterCreate(scope *gorm.Scope) (err error)

AfterCreate is a gorm hook that trims heads after its creation

func (*Head) GreaterThan Uses

func (l *Head) GreaterThan(r *Head) bool

GreaterThan compares BlockNumbers and returns true if the receiver BlockNumber is greater than the supplied BlockNumber

func (*Head) NextInt Uses

func (l *Head) NextInt() *big.Int

NextInt returns the next BlockNumber as big.int, or nil if nil to represent latest.

func (*Head) String Uses

func (l *Head) String() string

String returns a string representation of this number.

func (*Head) ToInt Uses

func (l *Head) ToInt() *big.Int

ToInt return the height as a *big.Int. Also handles nil by returning nil.

type ID Uses

type ID uuid.UUID

ID is a UUID that has a custom display format

func NewID Uses

func NewID() *ID

NewID returns a new ID

func NewIDFromString Uses

func NewIDFromString(input string) (*ID, error)

NewIDFromString is a convenience function to return an id from an input string

func (*ID) Bytes Uses

func (id *ID) Bytes() []byte

Bytes returns the raw bytes of the underlying UUID

func (*ID) MarshalText Uses

func (id *ID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler, using String()

func (*ID) Scan Uses

func (id *ID) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (*ID) String Uses

func (id *ID) String() string

String satisfies the Stringer interface and removes all '-'s from the string representation of the uuid

func (*ID) UnmarshalString Uses

func (id *ID) UnmarshalString(input string) error

UnmarshalString is a wrapper for UnmarshalText which takes a string

func (*ID) UnmarshalText Uses

func (id *ID) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (*ID) Value Uses

func (id *ID) Value() (driver.Value, error)

Value returns this instance serialized for database storage.

type Initiator Uses

type Initiator struct {
    ID        uint `json:"id" gorm:"primary_key;auto_increment"`
    JobSpecID *ID  `json:"jobSpecId" gorm:"index;type:varchar(36) REFERENCES job_specs(id)"`

    // Type is one of the Initiator* string constants defined just above.
    Type            string    `json:"type" gorm:"index;not null"`
    CreatedAt       time.Time `json:"createdAt" gorm:"index"`
    InitiatorParams `json:"params,omitempty"`
    DeletedAt       null.Time `json:"-" gorm:"index"`
}

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 NewInitiatorFromRequest Uses

func NewInitiatorFromRequest(
    initr InitiatorRequest,
    jobSpec JobSpec,
) Initiator

NewInitiatorFromRequest creates an Initiator from the corresponding parameters in a InitiatorRequest

func (Initiator) IsLogInitiated Uses

func (i Initiator) IsLogInitiated() bool

IsLogInitiated Returns true if triggered by event logs.

type InitiatorLogEvent Uses

type InitiatorLogEvent struct {
    Log       eth.Log
    Initiator Initiator
}

InitiatorLogEvent encapsulates all information as a result of a received log from an InitiatorSubscription, and acts as a base struct for other log-initiated events

func (InitiatorLogEvent) BlockNumber Uses

func (le InitiatorLogEvent) BlockNumber() *big.Int

BlockNumber returns the block number for the given InitiatorSubscriptionLogEvent.

func (InitiatorLogEvent) ForLogger Uses

func (le InitiatorLogEvent) ForLogger(kvs ...interface{}) []interface{}

ForLogger formats the InitiatorSubscriptionLogEvent for easy common formatting in logs (trace statements, not ethereum events).

func (InitiatorLogEvent) GetInitiator Uses

func (le InitiatorLogEvent) GetInitiator() Initiator

GetInitiator returns the initiator.

func (InitiatorLogEvent) GetJobSpecID Uses

func (le InitiatorLogEvent) GetJobSpecID() *ID

GetJobSpecID returns the associated JobSpecID

func (InitiatorLogEvent) GetLog Uses

func (le InitiatorLogEvent) GetLog() eth.Log

GetLog returns the log.

func (InitiatorLogEvent) JSON Uses

func (le InitiatorLogEvent) JSON() (JSON, error)

JSON returns the eth log as JSON.

func (InitiatorLogEvent) LogRequest Uses

func (le InitiatorLogEvent) LogRequest() LogRequest

LogRequest is a factory method that coerces this log event to the correct type based on Initiator.Type, exposed by the LogRequest interface.

func (InitiatorLogEvent) RunRequest Uses

func (le InitiatorLogEvent) RunRequest() (RunRequest, error)

RunRequest returns a run request instance with the transaction hash, present on all log initiated runs.

func (InitiatorLogEvent) ToDebug Uses

func (le InitiatorLogEvent) ToDebug()

ToDebug prints this event via logger.Debug.

func (InitiatorLogEvent) Validate Uses

func (le InitiatorLogEvent) Validate() bool

Validate returns true, no validation on this log event type.

func (InitiatorLogEvent) ValidateRequester Uses

func (le InitiatorLogEvent) ValidateRequester() error

ValidateRequester returns true since all requests are valid for base initiator log events.

type InitiatorParams Uses

type InitiatorParams struct {
    Schedule   Cron              `json:"schedule,omitempty"`
    Time       AnyTime           `json:"time,omitempty"`
    Ran        bool              `json:"ran,omitempty"`
    Address    common.Address    `json:"address,omitempty" gorm:"index"`
    Requesters AddressCollection `json:"requesters,omitempty" gorm:"type:text"`
    Name       string            `json:"name,omitempty"`
    Body       *JSON             `json:"body,omitempty" gorm:"column:params"`
    FromBlock  *utils.Big        `json:"fromBlock,omitempty" gorm:"type:varchar(255)"`
    ToBlock    *utils.Big        `json:"toBlock,omitempty" gorm:"type:varchar(255)"`
    Topics     Topics            `json:"topics,omitempty" gorm:"type:text"`

    RequestData     JSON     `json:"requestData,omitempty" gorm:"type:text"`
    IdleThreshold   Duration `json:"idleThreshold,omitempty"`
    Feeds           Feeds    `json:"feeds,omitempty" gorm:"type:text"`
    Threshold       float32  `json:"threshold,omitempty" gorm:"type:float"`
    Precision       int32    `json:"precision,omitempty" gorm:"type:smallint"`
    PollingInterval Duration `json:"pollingInterval,omitempty"`
}

InitiatorParams is a collection of the possible parameters that different Initiators may require.

func (*InitiatorParams) SetDefaultValues Uses

func (i *InitiatorParams) SetDefaultValues(typ string)

SetDefaultValues returns a InitiatorParams with empty fields set to their default value.

type InitiatorRequest Uses

type InitiatorRequest struct {
    Type            string `json:"type"`
    InitiatorParams `json:"params,omitempty"`
}

InitiatorRequest represents a schema for incoming initiator requests as used by the API.

type JSON Uses

type JSON struct {
    gjson.Result
}

JSON stores the json types string, number, bool, and null. Arrays and Objects are returned as their raw json types.

func Merge Uses

func Merge(inputs ...JSON) (JSON, error)

Merge returns a new map with all keys merged from right to left

func ParseCBOR Uses

func ParseCBOR(b []byte) (JSON, error)

ParseCBOR attempts to coerce the input byte array into valid CBOR and then coerces it into a JSON object.

func ParseJSON Uses

func ParseJSON(b []byte) (JSON, error)

ParseJSON attempts to coerce the input byte array into valid JSON and parse it into a JSON object.

func ParseRunLog Uses

func ParseRunLog(log eth.Log) (JSON, error)

ParseRunLog decodes the CBOR in the ABI of the log event.

func (JSON) Add Uses

func (j JSON) Add(insertKey string, insertValue interface{}) (JSON, error)

Add returns a new instance of JSON with the new value added.

func (JSON) AsMap Uses

func (j JSON) AsMap() (map[string]interface{}, error)

AsMap returns j as a map

func (JSON) Bytes Uses

func (j JSON) Bytes() []byte

Bytes returns the raw JSON.

func (JSON) CBOR Uses

func (j JSON) CBOR() ([]byte, error)

CBOR returns a bytes array of the JSON map or array encoded to CBOR.

func (JSON) Delete Uses

func (j JSON) Delete(key string) (JSON, error)

Delete returns a new instance of JSON with the specified key removed.

func (JSON) MarshalJSON Uses

func (j JSON) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON data if it already exists, returns an empty JSON object as bytes if not.

func (JSON) MultiAdd Uses

func (j JSON) MultiAdd(keyValues KV) (JSON, error)

MultiAdd returns a new instance of j with the new values added.

func (*JSON) Scan Uses

func (j *JSON) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (*JSON) UnmarshalJSON Uses

func (j *JSON) UnmarshalJSON(b []byte) error

UnmarshalJSON parses the JSON bytes and stores in the *JSON pointer.

func (JSON) Value Uses

func (j JSON) Value() (driver.Value, error)

Value returns this instance serialized for database storage.

type JSONAPIError Uses

type JSONAPIError struct {
    Detail string `json:"detail"`
}

JSONAPIError is an individual JSONAPI Error.

type JSONAPIErrors Uses

type JSONAPIErrors struct {
    Errors []JSONAPIError `json:"errors"`
}

JSONAPIErrors holds errors conforming to the JSONAPI spec.

func NewJSONAPIErrors Uses

func NewJSONAPIErrors() *JSONAPIErrors

NewJSONAPIErrors creates an instance of JSONAPIErrors, with the intention of managing a collection of them.

func NewJSONAPIErrorsWith Uses

func NewJSONAPIErrorsWith(detail string) *JSONAPIErrors

NewJSONAPIErrorsWith creates an instance of JSONAPIErrors populated with this single detail.

func (*JSONAPIErrors) Add Uses

func (jae *JSONAPIErrors) Add(detail string)

Add adds a new error to JSONAPIErrors with the passed detail.

func (*JSONAPIErrors) CoerceEmptyToNil Uses

func (jae *JSONAPIErrors) CoerceEmptyToNil() error

CoerceEmptyToNil will return nil if JSONAPIErrors has no errors.

func (*JSONAPIErrors) Error Uses

func (jae *JSONAPIErrors) Error() string

Error collapses the collection of errors into a collection of comma separated strings.

func (*JSONAPIErrors) Merge Uses

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 Uses

type JobRun struct {
    ID             *ID          `json:"id" gorm:"primary_key;not null"`
    JobSpecID      *ID          `json:"jobId" gorm:"index;not null;type:varchar(36) REFERENCES job_specs(id)"`
    Result         RunResult    `json:"result"`
    ResultID       uint         `json:"-"`
    RunRequest     RunRequest   `json:"-"`
    RunRequestID   uint         `json:"-"`
    Status         RunStatus    `json:"status" gorm:"index"`
    TaskRuns       []TaskRun    `json:"taskRuns"`
    CreatedAt      time.Time    `json:"createdAt" gorm:"index"`
    FinishedAt     null.Time    `json:"finishedAt"`
    UpdatedAt      time.Time    `json:"updatedAt"`
    Initiator      Initiator    `json:"initiator" gorm:"association_autoupdate:false;association_autocreate:false"`
    InitiatorID    uint         `json:"-"`
    CreationHeight *utils.Big   `json:"creationHeight"`
    ObservedHeight *utils.Big   `json:"observedHeight"`
    DeletedAt      null.Time    `json:"-" gorm:"index"`
    Payment        *assets.Link `json:"payment,omitempty"`
}

JobRun tracks the status of a job by holding its TaskRuns and the Result of each Run.

func MakeJobRun Uses

func MakeJobRun(job *JobSpec, now time.Time, initiator *Initiator, currentHeight *big.Int, runRequest *RunRequest) JobRun

MakeJobRun returns a new JobRun copy

func (*JobRun) ApplyBridgeRunResult Uses

func (jr *JobRun) ApplyBridgeRunResult(result BridgeRunResult)

ApplyBridgeRunResult saves the input from a BridgeAdapter

func (*JobRun) ApplyOutput Uses

func (jr *JobRun) ApplyOutput(result RunOutput)

ApplyOutput updates the JobRun's Result and Status

func (*JobRun) Cancel Uses

func (jr *JobRun) Cancel()

Cancel sets this run as cancelled, it should no longer be processed.

func (*JobRun) ErrorString Uses

func (jr *JobRun) ErrorString() string

ErrorString returns the error as a string if present, otherwise "".

func (JobRun) ForLogger Uses

func (jr JobRun) ForLogger(kvs ...interface{}) []interface{}

ForLogger formats the JobRun for a common formatting in the log.

func (JobRun) GetID Uses

func (jr JobRun) GetID() string

GetID returns the ID of this structure for jsonapi serialization.

func (JobRun) GetName Uses

func (jr JobRun) GetName() string

GetName returns the pluralized "type" of this structure for jsonapi serialization.

func (*JobRun) GetStatus Uses

func (jr *JobRun) GetStatus() RunStatus

GetStatus returns the JobRun's RunStatus

func (JobRun) HasError Uses

func (jr JobRun) HasError() bool

HasError returns true if this JobRun has errored

func (*JobRun) NextTaskRun Uses

func (jr *JobRun) NextTaskRun() *TaskRun

NextTaskRun returns the next immediate TaskRun in the list of unfinished TaskRuns.

func (*JobRun) NextTaskRunIndex Uses

func (jr *JobRun) NextTaskRunIndex() (int, bool)

NextTaskRunIndex returns the position of the next unfinished task

func (*JobRun) PreviousTaskRun Uses

func (jr *JobRun) PreviousTaskRun() *TaskRun

PreviousTaskRun returns the last task to be processed, if it exists

func (*JobRun) SetError Uses

func (jr *JobRun) SetError(err error)

SetError sets this job run to failed and saves the error message

func (*JobRun) SetID Uses

func (jr *JobRun) SetID(value string) error

SetID is used to set the ID of this structure when deserializing from jsonapi documents.

func (*JobRun) SetStatus Uses

func (jr *JobRun) SetStatus(status RunStatus)

SetStatus updates run status.

func (*JobRun) TasksRemain Uses

func (jr *JobRun) TasksRemain() bool

TasksRemain returns true if there are unfinished tasks left for this job run

type JobSpec Uses

type JobSpec struct {
    ID         *ID          `json:"id,omitempty" gorm:"primary_key;not null"`
    CreatedAt  time.Time    `json:"createdAt" gorm:"index"`
    Initiators []Initiator  `json:"initiators"`
    MinPayment *assets.Link `json:"minPayment,omitempty" gorm:"type:varchar(255)"`
    Tasks      []TaskSpec   `json:"tasks"`
    StartAt    null.Time    `json:"startAt" gorm:"index"`
    EndAt      null.Time    `json:"endAt" gorm:"index"`
    DeletedAt  null.Time    `json:"-" gorm:"index"`
}

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 Uses

func NewJob() JobSpec

NewJob initializes a new job by generating a unique ID and setting the CreatedAt field to the time of invokation.

func NewJobFromRequest Uses

func NewJobFromRequest(jsr JobSpecRequest) JobSpec

NewJobFromRequest creates a JobSpec from the corresponding parameters in a JobSpecRequest

func (JobSpec) Archived Uses

func (j JobSpec) Archived() bool

Archived returns true if the job spec has been soft deleted

func (JobSpec) Ended Uses

func (j JobSpec) Ended(t time.Time) bool

Ended returns true if the job has ended.

func (JobSpec) GetID Uses

func (j JobSpec) GetID() string

GetID returns the ID of this structure for jsonapi serialization.

func (JobSpec) GetName Uses

func (j JobSpec) GetName() string

GetName returns the pluralized "type" of this structure for jsonapi serialization.

func (JobSpec) InitiatorExternal Uses

func (j JobSpec) InitiatorExternal(name string) *Initiator

InitiatorExternal finds the Job Spec's Initiator field associated with the External Initiator's name using a case insensitive search.

Returns nil if not found.

func (JobSpec) InitiatorsFor Uses

func (j JobSpec) InitiatorsFor(types ...string) []Initiator

InitiatorsFor returns an array of Initiators for the given list of Initiator types.

func (JobSpec) IsLogInitiated Uses

func (j JobSpec) IsLogInitiated() bool

IsLogInitiated Returns true if any of the job's initiators are triggered by event logs.

func (*JobSpec) SetID Uses

func (j *JobSpec) SetID(value string) error

SetID is used to set the ID of this structure when deserializing from jsonapi documents.

func (JobSpec) Started Uses

func (j JobSpec) Started(t time.Time) bool

Started returns true if the job has started.

type JobSpecRequest Uses

type JobSpecRequest struct {
    Initiators []InitiatorRequest `json:"initiators"`
    Tasks      []TaskSpecRequest  `json:"tasks"`
    StartAt    null.Time          `json:"startAt"`
    EndAt      null.Time          `json:"endAt"`
    MinPayment *assets.Link       `json:"minPayment,omitempty"`
}

JobSpecRequest represents a schema for the incoming job spec request as used by the API.

type KV Uses

type KV map[string]interface{}

KV represents a key/value pair to be added to a JSON object

type Key Uses

type Key struct {
    Address EIP55Address `gorm:"primary_key;type:varchar(64)"`
    JSON    JSON         `gorm:"type:text"`
}

Key holds the private key metadata for a given address that is used to unlock said key when given a password.

By default, a key is assumed to represent an ethereum account.

func NewKeyFromFile Uses

func NewKeyFromFile(path string) (*Key, error)

NewKeyFromFile creates an instance in memory from a key file on disk.

func (*Key) WriteToDisk Uses

func (k *Key) WriteToDisk(path string) error

WriteToDisk writes this key to disk at the passed path.

type LogCursor Uses

type LogCursor struct {
    Name        string `gorm:"primary_key"`
    Initialized bool   `gorm:"not null;default true"`
    BlockIndex  uint64 `gorm:"not null;default 0"`
    LogIndex    uint64 `gorm:"not null;default 0"`
}

type LogRequest Uses

type LogRequest interface {
    GetLog() eth.Log
    GetJobSpecID() *ID
    GetInitiator() Initiator

    Validate() bool
    JSON() (JSON, error)
    ToDebug()
    ForLogger(kvs ...interface{}) []interface{}
    ValidateRequester() error
    BlockNumber() *big.Int
    RunRequest() (RunRequest, error)
}

LogRequest is the interface to allow polymorphic functionality of different types of LogEvents. i.e. EthLogEvent, RunLogEvent, ServiceAgreementLogEvent, OracleLogEvent

type PublicKey Uses

type PublicKey = vrfkey.PublicKey

type RandomnessLogEvent Uses

type RandomnessLogEvent struct{ InitiatorLogEvent }

RandomnessLogEvent provides functionality specific to a log event emitted for a run log initiator.

func (RandomnessLogEvent) JSON Uses

func (le RandomnessLogEvent) JSON() (js JSON, err error)

JSON returns the JSON from this RandomnessRequest log, as it will be passed to the Randomn adapter

func (RandomnessLogEvent) Requester Uses

func (le RandomnessLogEvent) Requester() common.Address

Requester pulls the requesting address out of the LogEvent's topics.

func (RandomnessLogEvent) RunRequest Uses

func (le RandomnessLogEvent) RunRequest() (RunRequest, error)

RunRequest returns a RunRequest instance with all parameters from a run log topic, like RequestID.

func (RandomnessLogEvent) Validate Uses

func (le RandomnessLogEvent) Validate() bool

Validate() is true if the contained log is parseable as a RandomnessRequest, and it's from the address specified by the job's initiator. The log filter and the go-ethereum parser should prevent any invalid logs from reacching this point, so Validate emits an error log on failure.

func (RandomnessLogEvent) ValidateRequester Uses

func (le RandomnessLogEvent) ValidateRequester() error

ValidateRequester never errors, because the requester is not important to the node's functionality. A requesting contract cannot request the VRF output on behalf of another contract, because the initial input seed is hashed with the requesting contract's address (plus a nonce) to get the actual VRF input.

type RunInput Uses

type RunInput struct {
    // contains filtered or unexported fields
}

RunInput represents the input for performing a Task

func NewRunInput Uses

func NewRunInput(jobRunID *ID, data JSON, status RunStatus) *RunInput

NewRunInput creates a new RunInput with arbitrary data

func NewRunInputWithResult Uses

func NewRunInputWithResult(jobRunID *ID, value interface{}, status RunStatus) *RunInput

NewRunInputWithResult creates a new RunInput with a value in the "result" field

func (RunInput) Data Uses

func (ri RunInput) Data() JSON

Data returns the RunInput's data

func (RunInput) JobRunID Uses

func (ri RunInput) JobRunID() *ID

JobRunID returns this RunInput's JobRunID

func (RunInput) Result Uses

func (ri RunInput) Result() gjson.Result

Result returns the result as a gjson object

func (RunInput) ResultString Uses

func (ri RunInput) ResultString() (string, error)

ResultString returns the string result of the Data JSON field.

func (RunInput) Status Uses

func (ri RunInput) Status() RunStatus

Status returns the RunInput's status

type RunLogEvent Uses

type RunLogEvent struct {
    InitiatorLogEvent
}

RunLogEvent provides functionality specific to a log event emitted for a run log initiator.

func (RunLogEvent) JSON Uses

func (le RunLogEvent) JSON() (JSON, error)

JSON decodes the RunLogEvent's data converts it to a JSON object.

func (RunLogEvent) Requester Uses

func (le RunLogEvent) Requester() (common.Address, error)

Requester pulls the requesting address out of the LogEvent's topics.

func (RunLogEvent) RunRequest Uses

func (le RunLogEvent) RunRequest() (RunRequest, error)

RunRequest returns an RunRequest instance with all parameters from a run log topic, like RequestID.

func (RunLogEvent) Validate Uses

func (le RunLogEvent) Validate() bool

Validate returns whether or not the contained log has a properly encoded job id.

func (RunLogEvent) ValidateRequester Uses

func (le RunLogEvent) ValidateRequester() error

ValidateRequester returns true if the requester matches the one associated with the initiator.

type RunOutput Uses

type RunOutput struct {
    // contains filtered or unexported fields
}

RunOutput represents the result of performing a Task

func NewRunOutputComplete Uses

func NewRunOutputComplete(data JSON) RunOutput

NewRunOutputComplete returns a new RunOutput that is complete and contains raw data

func NewRunOutputCompleteWithResult Uses

func NewRunOutputCompleteWithResult(resultVal interface{}) RunOutput

NewRunOutputCompleteWithResult returns a new RunOutput that is complete and contains a result

func NewRunOutputError Uses

func NewRunOutputError(err error) RunOutput

NewRunOutputError returns a new RunOutput with an error

func NewRunOutputInProgress Uses

func NewRunOutputInProgress(data JSON) RunOutput

NewRunOutputInProgress returns a new RunOutput that indicates the task is still in progress

func NewRunOutputPendingBridge Uses

func NewRunOutputPendingBridge() RunOutput

NewRunOutputPendingBridge returns a new RunOutput that indicates the task is still in progress

func NewRunOutputPendingConfirmationsWithData Uses

func NewRunOutputPendingConfirmationsWithData(data JSON) RunOutput

NewRunOutputPendingConfirmationsWithData returns a new RunOutput that indicates the task is pending confirmations but also has some data that needs to be fed in on next invocation

func NewRunOutputPendingConnection Uses

func NewRunOutputPendingConnection() RunOutput

NewRunOutputPendingConnection returns a new RunOutput that indicates the task got disconnected

func NewRunOutputPendingConnectionWithData Uses

func NewRunOutputPendingConnectionWithData(data JSON) RunOutput

NewRunOutputPendingConnectionWithData returns a new RunOutput that indicates the task got disconnected but also has some data that needs to be fed in on next invocation

func (RunOutput) Data Uses

func (ro RunOutput) Data() JSON

Data returns the data held by this RunOutput

func (RunOutput) Error Uses

func (ro RunOutput) Error() error

Error returns error for this RunOutput

func (RunOutput) Get Uses

func (ro RunOutput) Get(path string) gjson.Result

Get searches for and returns the JSON at the given path.

func (RunOutput) HasError Uses

func (ro RunOutput) HasError() bool

HasError returns true if the status is errored or the error message is set

func (RunOutput) Result Uses

func (ro RunOutput) Result() gjson.Result

Result returns the result as a gjson object

func (RunOutput) Status Uses

func (ro RunOutput) Status() RunStatus

Status returns the status returned from a task

type RunRequest Uses

type RunRequest struct {
    ID            uint `gorm:"primary_key"`
    RequestID     *string
    TxHash        *common.Hash
    BlockHash     *common.Hash
    Requester     *common.Address
    CreatedAt     time.Time
    Payment       *assets.Link
    RequestParams JSON `gorm:"default: '{}';not null"`
}

RunRequest stores the fields used to initiate the parent job run.

func NewRunRequest Uses

func NewRunRequest(requestParams JSON) *RunRequest

NewRunRequest returns a new RunRequest instance.

type RunResult Uses

type RunResult struct {
    ID           uint        `json:"-" gorm:"primary_key;auto_increment"`
    Data         JSON        `json:"data" gorm:"type:text"`
    ErrorMessage null.String `json:"error"`
}

RunResult keeps track of the outcome of a TaskRun or JobRun. It stores the Data and ErrorMessage.

type RunStatus Uses

type RunStatus string

RunStatus is a string that represents the run status

func (RunStatus) CanStart Uses

func (s RunStatus) CanStart() bool

CanStart returns true if the run is ready to begin processed.

func (RunStatus) Cancelled Uses

func (s RunStatus) Cancelled() bool

Cancelled returns true if the status is RunStatusCancelled.

func (RunStatus) Completed Uses

func (s RunStatus) Completed() bool

Completed returns true if the status is RunStatusCompleted.

func (RunStatus) Errored Uses

func (s RunStatus) Errored() bool

Errored returns true if the status is RunStatusErrored.

func (RunStatus) Finished Uses

func (s RunStatus) Finished() bool

Finished returns true if the status is final and can't be changed.

func (RunStatus) Pending Uses

func (s RunStatus) Pending() bool

Pending returns true if the status is pending external or confirmations.

func (RunStatus) PendingBridge Uses

func (s RunStatus) PendingBridge() bool

PendingBridge returns true if the status is pending_bridge.

func (RunStatus) PendingConfirmations Uses

func (s RunStatus) PendingConfirmations() bool

PendingConfirmations returns true if the status is pending_confirmations.

func (RunStatus) PendingConnection Uses

func (s RunStatus) PendingConnection() bool

PendingConnection returns true if the status is pending_connection.

func (RunStatus) PendingSleep Uses

func (s RunStatus) PendingSleep() bool

PendingSleep returns true if the status is pending_sleep.

func (RunStatus) Runnable Uses

func (s RunStatus) Runnable() bool

Runnable returns true if the status is ready to be run.

func (*RunStatus) Scan Uses

func (s *RunStatus) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (RunStatus) Unstarted Uses

func (s RunStatus) Unstarted() bool

Unstarted returns true if the status is the initial state.

func (RunStatus) Value Uses

func (s RunStatus) Value() (driver.Value, error)

Value returns this instance serialized for database storage.

type RunStatusCollection Uses

type RunStatusCollection []RunStatus

RunStatusCollection is an array of RunStatus.

func (*RunStatusCollection) Scan Uses

func (r *RunStatusCollection) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (RunStatusCollection) ToStrings Uses

func (r RunStatusCollection) ToStrings() []string

ToStrings returns a copy of RunStatusCollection as an array of strings.

func (RunStatusCollection) Value Uses

func (r RunStatusCollection) Value() (driver.Value, error)

Value returns this instance serialized for database storage.

type SendEtherRequest Uses

type SendEtherRequest struct {
    DestinationAddress common.Address `json:"address"`
    FromAddress        common.Address `json:"from"`
    Amount             *assets.Eth    `json:"amount"`
}

SendEtherRequest represents a request to transfer ETH.

type ServiceAgreement Uses

type ServiceAgreement struct {
    ID            string      `json:"id" gorm:"primary_key"`
    CreatedAt     time.Time   `json:"createdAt" gorm:"index"`
    Encumbrance   Encumbrance `json:"encumbrance"`
    EncumbranceID uint        `json:"-"`
    RequestBody   string      `json:"requestBody"`
    Signature     Signature   `json:"signature" gorm:"type:varchar(255)"`
    JobSpec       JobSpec     `gorm:"foreignkey:JobSpecID"`
    JobSpecID     *ID         `json:"jobSpecId"`
}

ServiceAgreement connects job specifications with on-chain encumbrances.

func BuildServiceAgreement Uses

func BuildServiceAgreement(us UnsignedServiceAgreement, signer Signer) (ServiceAgreement, error)

BuildServiceAgreement builds a signed service agreement

func (ServiceAgreement) GetID Uses

func (sa ServiceAgreement) GetID() string

GetID returns the ID of this structure for jsonapi serialization.

func (ServiceAgreement) GetName Uses

func (sa ServiceAgreement) GetName() string

GetName returns the pluralized "type" of this structure for jsonapi serialization.

func (*ServiceAgreement) SetID Uses

func (sa *ServiceAgreement) SetID(value string) error

SetID is used to set the ID of this structure when deserializing from jsonapi documents.

type ServiceAgreementRequest Uses

type ServiceAgreementRequest struct {
    Initiators             []InitiatorRequest     `json:"initiators"`
    Tasks                  []TaskSpecRequest      `json:"tasks"`
    Payment                *assets.Link           `json:"payment,omitempty"`
    Expiration             uint64                 `json:"expiration"`
    EndAt                  AnyTime                `json:"endAt"`
    Oracles                EIP55AddressCollection `json:"oracles"`
    Aggregator             EIP55Address           `json:"aggregator"`
    AggInitiateJobSelector eth.FunctionSelector   `json:"aggInitiateJobSelector"`
    AggFulfillSelector     eth.FunctionSelector   `json:"aggFulfillSelector"`
    StartAt                AnyTime                `json:"startAt"`
}

ServiceAgreementRequest encodes external ServiceAgreement json representation.

type Session Uses

type Session struct {
    ID        string    `json:"id" gorm:"primary_key"`
    LastUsed  time.Time `json:"lastUsed" gorm:"index"`
    CreatedAt time.Time `json:"createdAt" gorm:"index"`
}

Session holds the unique id for the authenticated session.

func NewSession Uses

func NewSession() Session

NewSession returns a session instance with ID set to a random ID and LastUsed to to now.

type SessionRequest Uses

type SessionRequest struct {
    Email    string `json:"email"`
    Password string `json:"password"`
}

SessionRequest encapsulates the fields needed to generate a new SessionID, including the hashed password.

type Signature Uses

type Signature [SignatureLength]byte

Signature is a byte array fixed to the size of a signature

func BytesToSignature Uses

func BytesToSignature(b []byte) Signature

BytesToSignature converts an arbitrary length byte array to a Signature

func NewSignature Uses

func NewSignature(s string) (Signature, error)

NewSignature returns a new Signature

func (Signature) Big Uses

func (s Signature) Big() *big.Int

Big returns a big.Int representation

func (Signature) Bytes Uses

func (s Signature) Bytes() []byte

Bytes returns the raw bytes

func (Signature) Format Uses

func (s Signature) Format(state fmt.State, c rune)

Format implements fmt.Formatter

func (Signature) Hex Uses

func (s Signature) Hex() string

Hex returns a hexadecimal string

func (Signature) MarshalJSON Uses

func (s Signature) MarshalJSON() ([]byte, error)

MarshalJSON prints the signature as a hexadecimal encoded string

func (Signature) MarshalText Uses

func (s Signature) MarshalText() ([]byte, error)

MarshalText encodes the signature in hexadecimal

func (*Signature) Scan Uses

func (s *Signature) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (*Signature) SetBytes Uses

func (s *Signature) SetBytes(b []byte)

SetBytes assigns the byte array to the signature

func (Signature) String Uses

func (s Signature) String() string

String implements the stringer interface and is used also by the logger.

func (*Signature) UnmarshalJSON Uses

func (s *Signature) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a signature from a JSON string

func (*Signature) UnmarshalText Uses

func (s *Signature) UnmarshalText(input []byte) error

UnmarshalText parses the signature from a hexadecimal representation

func (Signature) Value Uses

func (s Signature) Value() (driver.Value, error)

Value returns this instance serialized for database storage.

type Signer Uses

type Signer interface {
    SignHash(hash common.Hash) (Signature, error)
}

Signer is used to produce a HMAC signature from an input digest

type SyncEvent Uses

type SyncEvent struct {
    ID        uint `gorm:"primary_key"`
    CreatedAt time.Time
    UpdatedAt time.Time
    Body      string
}

SyncEvent represents an event sourcing style event, which is used to sync data upstream with another service

type TaskRun Uses

type TaskRun struct {
    ID                   *ID           `json:"id" gorm:"primary_key;not null"`
    JobRunID             *ID           `json:"-" gorm:"index;not null;type:varchar(36) REFERENCES job_runs(id) ON DELETE CASCADE"`
    Result               RunResult     `json:"result"`
    ResultID             uint          `json:"-"`
    Status               RunStatus     `json:"status"`
    TaskSpec             TaskSpec      `json:"task" gorm:"association_autoupdate:false;association_autocreate:false"`
    TaskSpecID           uint          `json:"-" gorm:"index;not null REFERENCES task_specs(id)"`
    MinimumConfirmations clnull.Uint32 `json:"minimumConfirmations"`
    Confirmations        clnull.Uint32 `json:"confirmations"`
    CreatedAt            time.Time     `json:"-" gorm:"index"`
}

TaskRun stores the Task and represents the status of the Task to be ran.

func (*TaskRun) ApplyBridgeRunResult Uses

func (tr *TaskRun) ApplyBridgeRunResult(result BridgeRunResult)

ApplyBridgeRunResult updates the TaskRun's Result and Status

func (*TaskRun) ApplyOutput Uses

func (tr *TaskRun) ApplyOutput(result RunOutput)

ApplyOutput updates the TaskRun's Result and Status

func (*TaskRun) SetError Uses

func (tr *TaskRun) SetError(err error)

SetError sets this task run to failed and saves the error message

func (TaskRun) String Uses

func (tr TaskRun) String() string

String returns info on the TaskRun as "ID,Type,Status,Result".

type TaskSpec Uses

type TaskSpec struct {
    gorm.Model
    JobSpecID     *ID           `json:"-"`
    Type          TaskType      `json:"type" gorm:"index;not null"`
    Confirmations clnull.Uint32 `json:"confirmations"`
    Params        JSON          `json:"params" gorm:"type:text"`
}

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 TaskSpecRequest Uses

type TaskSpecRequest struct {
    Type          TaskType      `json:"type"`
    Confirmations clnull.Uint32 `json:"confirmations"`
    Params        JSON          `json:"params"`
}

TaskSpecRequest represents a schema for incoming TaskSpec requests as used by the API.

type TaskType Uses

type TaskType string

TaskType defines what Adapter a TaskSpec will use.

func MustNewTaskType Uses

func MustNewTaskType(val string) TaskType

MustNewTaskType instantiates a new TaskType, and panics if a bad input is provided.

func NewTaskType Uses

func NewTaskType(val string) (TaskType, error)

NewTaskType returns a formatted Task type.

func (TaskType) MarshalJSON Uses

func (t TaskType) MarshalJSON() ([]byte, error)

MarshalJSON converts a TaskType to a JSON byte slice.

func (*TaskType) Scan Uses

func (t *TaskType) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (TaskType) String Uses

func (t TaskType) String() string

String returns this TaskType as a string.

func (*TaskType) UnmarshalJSON Uses

func (t *TaskType) UnmarshalJSON(input []byte) error

UnmarshalJSON converts a bytes slice of JSON to a TaskType.

func (TaskType) Value Uses

func (t TaskType) Value() (driver.Value, error)

Value returns this instance serialized for database storage.

type Topics Uses

type Topics [][]common.Hash

Topics handle the serialization of ethereum log topics to and from the data store.

func (Topics) Scan Uses

func (t Topics) Scan(value interface{}) error

Scan coerces the value returned from the data store to the proper data in this instance.

func (Topics) Value Uses

func (t Topics) Value() (driver.Value, error)

Value returns this instance serialized for database storage.

type Tx Uses

type Tx struct {
    ID  uint64 `gorm:"primary_key;auto_increment"`

    // SurrogateID is used to look up a transaction using a secondary ID, used to
    // associate jobs with transactions so that we don't double spend in certain
    // failure scenarios
    SurrogateID null.String `gorm:"index;unique"`

    Attempts []*TxAttempt `json:"-"`

    From     common.Address `gorm:"index;not null"`
    To       common.Address `gorm:"not null"`
    Data     []byte         `gorm:"not null"`
    Nonce    uint64         `gorm:"index;not null"`
    Value    *utils.Big     `gorm:"type:varchar(78);not null"`
    GasLimit uint64         `gorm:"not null"`

    // TxAttempt fields manually included; can't embed another primary_key
    Hash        common.Hash `gorm:"not null"`
    GasPrice    *utils.Big  `gorm:"type:varchar(78);not null"`
    Confirmed   bool        `gorm:"not null"`
    SentAt      uint64      `gorm:"not null"`
    SignedRawTx string      `gorm:"type:text;not null"`
}

Tx contains fields necessary for an Ethereum transaction with an additional field for the TxAttempt.

func (Tx) EthTx Uses

func (tx Tx) EthTx(gasPriceWei *big.Int) *types.Transaction

EthTx creates a new Ethereum transaction with a given gasPrice in wei that is ready to be signed.

func (*Tx) String Uses

func (tx *Tx) String() string

String implements Stringer for Tx

type TxAttempt Uses

type TxAttempt struct {
    ID  uint64 `gorm:"primary_key;auto_increment"`

    TxID uint64 `gorm:"index;type:bigint REFERENCES txes(id) ON DELETE CASCADE"`
    Tx   *Tx    `json:"-" gorm:"PRELOAD:false;foreignkey:TxID"`

    CreatedAt time.Time `gorm:"index;not null"`

    Hash        common.Hash `gorm:"index;not null"`
    GasPrice    *utils.Big  `gorm:"type:varchar(78);not null"`
    Confirmed   bool        `gorm:"not null"`
    SentAt      uint64      `gorm:"not null"`
    SignedRawTx string      `gorm:"type:text;not null"`
}

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.

func HighestPricedTxAttemptPerTx Uses

func HighestPricedTxAttemptPerTx(items []TxAttempt) []TxAttempt

func (TxAttempt) GetID Uses

func (txa TxAttempt) GetID() string

GetID returns the ID of this structure for jsonapi serialization.

func (TxAttempt) GetName Uses

func (txa TxAttempt) GetName() string

GetName returns the pluralized "type" of this structure for jsonapi serialization.

func (*TxAttempt) SetID Uses

func (txa *TxAttempt) SetID(value string) error

SetID is used to set the ID of this structure when deserializing from jsonapi documents.

func (*TxAttempt) String Uses

func (txa *TxAttempt) String() string

String implements Stringer for TxAttempt

type UnsignedServiceAgreement Uses

type UnsignedServiceAgreement struct {
    Encumbrance    Encumbrance
    ID             common.Hash
    RequestBody    string
    JobSpecRequest JobSpecRequest
}

UnsignedServiceAgreement contains the information to sign a service agreement

func NewUnsignedServiceAgreementFromRequest Uses

func NewUnsignedServiceAgreementFromRequest(reader io.Reader) (UnsignedServiceAgreement, error)

NewUnsignedServiceAgreementFromRequest builds the information required to sign a service agreement

type User Uses

type User struct {
    Email             string    `json:"email" gorm:"primary_key"`
    HashedPassword    string    `json:"hashedPassword"`
    CreatedAt         time.Time `json:"createdAt" gorm:"index"`
    TokenKey          string    `json:"tokenKey"`
    TokenSalt         string    `json:"-"`
    TokenHashedSecret string    `json:"-"`
}

User holds the credentials for API user.

func NewUser Uses

func NewUser(email, plainPwd string) (User, error)

NewUser creates a new user by hashing the passed plainPwd with bcrypt.

func (*User) DeleteAuthToken Uses

func (u *User) DeleteAuthToken()

DeleteAuthToken clears and disables the users Authentication Token.

func (*User) GenerateAuthToken Uses

func (u *User) GenerateAuthToken() (*auth.Token, error)

GenerateAuthToken randomly generates and sets the users Authentication Token.

func (*User) SetAuthToken Uses

func (u *User) SetAuthToken(token *auth.Token) error

SetAuthToken updates the user to use the given Authentication Token.

type ValidationError Uses

type ValidationError struct {
    // contains filtered or unexported fields
}

ValidationError is an error that occurs during validation.

func (*ValidationError) Error Uses

func (e *ValidationError) Error() string

type WebURL Uses

type WebURL url.URL

WebURL contains the URL of the endpoint.

func (WebURL) MarshalJSON Uses

func (w WebURL) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON-encoded string of the given data.

func (*WebURL) Scan Uses

func (w *WebURL) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (WebURL) String Uses

func (w WebURL) String() string

String delegates to the wrapped URL struct or an empty string when it is nil

func (*WebURL) UnmarshalJSON Uses

func (w *WebURL) UnmarshalJSON(j []byte) error

UnmarshalJSON parses the raw URL stored in JSON-encoded data to a URL structure and sets it to the URL field.

func (WebURL) Value Uses

func (w WebURL) Value() (driver.Value, error)

Value returns this instance serialized for database storage.

type WithdrawalRequest Uses

type WithdrawalRequest struct {
    DestinationAddress common.Address `json:"address"`
    ContractAddress    common.Address `json:"contractAddress"`
    Amount             *assets.Link   `json:"amount"`
}

WithdrawalRequest request to withdraw LINK.

Directories

PathSynopsis
vrfkeyPackage vrfkey tracks the secret keys associated with VRF proofs.

Package models imports 40 packages (graph). Updated 2020-04-08. Refresh now. Tools for package owners.

The go get command cannot install this package because of the following issues: