Documentation ¶
Overview ¶
Package models contain the key job components used by the Adamoracle 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 Adamoracle 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 ¶
- Constants
- Variables
- func AuthenticateBridgeType(bt *BridgeType, token string) (bool, error)
- func AuthenticateExternalInitiator(eia *auth.Token, ea *ExternalInitiator) (bool, error)
- func AuthenticateUserByToken(token *auth.Token, user *User) (bool, error)
- func CoerceInterfaceMapToStringMap(in interface{}) (interface{}, error)
- func FilterQueryFactory(i Initiator, from *big.Int, addresses ...common.Address) (q ethereum.FilterQuery, err error)
- func HexToInt64(input interface{}) int64
- func IDToHexTopic(id JobID) common.Hash
- func IDToTopic(id JobID) common.Hash
- func Int64ToHex(n int64) string
- func JobSpecIDTopics(jsID JobID) []common.Hash
- func MarshalBridgeMetaData(latestAnswer *big.Int, updatedAt *big.Int) (map[string]interface{}, error)
- func MarshalToMap(input interface{}) (map[string]interface{}, error)
- func NewBridgeType(btr *BridgeTypeRequest) (*BridgeTypeAuthentication, *BridgeType, error)
- func NewDatabaseAccessError(msg string) error
- func NewValidationError(msg string, values ...interface{}) error
- func ReceiptIndicatesRunLogFulfillment(txr types.Receipt) bool
- func ReceiptIsUnconfirmed(txr *types.Receipt) bool
- func VRFCoordinatorABI() abi.ABI
- func VRFFulfillMethod() abi.Method
- func VRFFulfillSelector() string
- func VRFRandomnessRequestLogTopic() common.Hash
- func ValidateBulkDeleteRunRequest(request *BulkDeleteRunRequest) error
- type AddressCollection
- type AnyTime
- type Block
- type BridgeMetaData
- type BridgeMetaDataJSON
- type BridgeRunResult
- type BridgeType
- type BridgeTypeAuthentication
- type BridgeTypeRequest
- type BulkDeleteRunRequest
- type ChangeAuthTokenRequest
- type Configuration
- type CreateJobSpecRequest
- type Cron
- type DatabaseAccessError
- type Duration
- func (d Duration) Before(t time.Time) time.Time
- func (d Duration) Duration() time.Duration
- func (d Duration) IsInstant() bool
- func (d Duration) MarshalJSON() ([]byte, error)
- func (d *Duration) Scan(v interface{}) (err error)
- func (d Duration) Shorter(od Duration) bool
- func (d Duration) String() string
- func (d *Duration) UnmarshalJSON(input []byte) error
- func (d Duration) Value() (driver.Value, error)
- 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) Hex() string
- func (a *EIP55Address) Scan(value interface{}) error
- func (a EIP55Address) String() string
- func (a *EIP55Address) UnmarshalJSON(input []byte) error
- func (a *EIP55Address) UnmarshalText(input []byte) error
- func (a EIP55Address) Value() (driver.Value, error)
- type EIP55AddressCollection
- type Encumbrance
- type EthLogEvent
- type EthReceipt
- type EthTaskRunTx
- type EthTx
- type EthTxAttempt
- type EthTxAttemptState
- type EthTxState
- type ExternalInitiator
- type ExternalInitiatorRequest
- type Feeds
- type FluxMonitorRoundStats
- type FunctionSelector
- func (f FunctionSelector) Bytes() []byte
- func (f FunctionSelector) MarshalJSON() ([]byte, error)
- func (f *FunctionSelector) Scan(value interface{}) error
- func (f *FunctionSelector) SetBytes(b []byte)
- func (f FunctionSelector) String() string
- func (f *FunctionSelector) UnmarshalJSON(input []byte) error
- func (f FunctionSelector) Value() (driver.Value, error)
- type Head
- func (h Head) ChainHashes() []common.Hash
- func (h Head) ChainLength() uint32
- func (h Head) EarliestInChain() Head
- func (h *Head) GreaterThan(r *Head) bool
- func (h Head) HashAtHeight(blockNum int64) common.Hash
- func (h Head) IsInChain(blockHash common.Hash) bool
- func (h *Head) MarshalJSON() ([]byte, error)
- func (h *Head) NextInt() *big.Int
- func (h *Head) String() string
- func (h *Head) ToInt() *big.Int
- func (h *Head) UnmarshalJSON(bs []byte) error
- type IdleTimerConfig
- type Initiator
- type InitiatorLogEvent
- func (le InitiatorLogEvent) BlockNumber() *big.Int
- func (le InitiatorLogEvent) ForLogger(kvs ...interface{}) []interface{}
- func (le InitiatorLogEvent) GetInitiator() Initiator
- func (le InitiatorLogEvent) GetJobSpecID() JobID
- func (le InitiatorLogEvent) GetLog() types.Log
- func (le InitiatorLogEvent) JSON() (JSON, error)
- func (le InitiatorLogEvent) LogRequest() LogRequest
- func (le InitiatorLogEvent) RunRequest() (RunRequest, error)
- func (le InitiatorLogEvent) ToDebug()
- func (le InitiatorLogEvent) Validate() bool
- func (le InitiatorLogEvent) ValidateRequester() error
- type InitiatorParams
- type InitiatorRequest
- type Interval
- type JSON
- func (j JSON) Add(insertKey string, insertValue interface{}) (JSON, error)
- func (j JSON) AsMap() (map[string]interface{}, error)
- func (j JSON) Bytes() []byte
- func (j JSON) CBOR() ([]byte, error)
- func (j JSON) Delete(key string) (JSON, error)
- func (JSON) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (JSON) GormDataType() string
- func (j JSON) MarshalJSON() ([]byte, error)
- func (j JSON) MultiAdd(keyValues KV) (JSON, error)
- func (j JSON) PrependAtArrayKey(insertKey string, insertValue interface{}) (JSON, error)
- func (j *JSON) Scan(value interface{}) error
- func (j *JSON) UnmarshalJSON(b []byte) error
- func (j *JSON) UnmarshalTOML(val interface{}) error
- func (j JSON) Value() (driver.Value, error)
- type JSONAPIError
- type JSONAPIErrors
- type JobID
- func (id JobID) IsZero() bool
- func (id JobID) MarshalText() ([]byte, error)
- func (id *JobID) Scan(src interface{}) error
- func (id JobID) String() string
- func (id JobID) UUID() uuid.UUID
- func (id *JobID) UnmarshalString(input string) error
- func (id *JobID) UnmarshalText(input []byte) error
- func (id JobID) Value() (driver.Value, error)
- type JobRun
- func (jr *JobRun) ApplyBridgeRunResult(result BridgeRunResult)
- func (jr *JobRun) ApplyOutput(result RunOutput)
- func (jr *JobRun) Cancel()
- func (jr *JobRun) ErrorString() string
- func (jr JobRun) ForLogger(kvs ...interface{}) []interface{}
- func (jr JobRun) GetID() string
- func (jr JobRun) GetName() string
- func (jr *JobRun) GetStatus() RunStatus
- func (jr JobRun) HasError() bool
- func (jr *JobRun) NextTaskRun() *TaskRun
- func (jr *JobRun) NextTaskRunIndex() (int, bool)
- func (jr *JobRun) PreviousTaskRun() *TaskRun
- func (jr *JobRun) SetError(err error)
- func (jr *JobRun) SetID(value string) error
- func (jr *JobRun) SetStatus(status RunStatus)
- func (jr *JobRun) TasksRemain() bool
- type JobSpec
- func (j JobSpec) Archived() bool
- func (j JobSpec) Ended(t time.Time) bool
- func (j JobSpec) GetID() string
- func (j JobSpec) GetName() string
- func (j JobSpec) InitiatorExternal(name string) *Initiator
- func (j JobSpec) InitiatorsFor(types ...string) []Initiator
- func (j JobSpec) IsLogInitiated() bool
- func (j *JobSpec) SetID(value string) error
- func (j JobSpec) Started(t time.Time) bool
- type JobSpecError
- type JobSpecRequest
- type KV
- type Key
- type LogCursor
- type LogRequest
- type NodeVersion
- type NullSigner
- type PeerID
- type PollTimerConfig
- type RandomnessLogEvent
- type RandomnessRequestLog
- type RawRandomnessRequestLog
- type RunInput
- func (ri RunInput) CloneWithData(data JSON) RunInput
- func (ri RunInput) Data() JSON
- func (ri RunInput) JobRunID() uuid.UUID
- func (ri RunInput) Result() gjson.Result
- func (ri RunInput) ResultCollection() gjson.Result
- func (ri RunInput) ResultString() (string, error)
- func (ri RunInput) Status() RunStatus
- func (ri RunInput) TaskRunID() uuid.UUID
- type RunLogEvent
- type RunOutput
- func NewRunOutputComplete(data JSON) RunOutput
- func NewRunOutputCompleteWithResult(resultVal interface{}, resultCollection gjson.Result) RunOutput
- func NewRunOutputError(err error) RunOutput
- func NewRunOutputInProgress(data JSON) RunOutput
- func NewRunOutputPendingBridge() RunOutput
- func NewRunOutputPendingConnection() RunOutput
- func NewRunOutputPendingConnectionWithData(data JSON) RunOutput
- func NewRunOutputPendingOutgoingConfirmationsWithData(data JSON) RunOutput
- type RunRequest
- type RunResult
- type RunStatus
- func (s RunStatus) Cancelled() 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) PendingConnection() bool
- func (s RunStatus) PendingIncomingConfirmations() bool
- func (s RunStatus) PendingOutgoingConfirmations() bool
- func (s RunStatus) PendingSleep() bool
- func (s RunStatus) Runnable() bool
- func (s *RunStatus) Scan(value interface{}) error
- func (s RunStatus) Unstarted() bool
- func (s RunStatus) Value() (driver.Value, error)
- type RunStatusCollection
- type SendEtherRequest
- type ServiceAgreement
- type ServiceAgreementRequest
- type Session
- type SessionRequest
- type Sha256Hash
- 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) Scan(value interface{}) 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
- func (s Signature) Value() (driver.Value, error)
- type Signer
- type SyncEvent
- type TaskRun
- type TaskSpec
- type TaskSpecRequest
- type TaskType
- type Topics
- type UnsignedServiceAgreement
- type UntrustedBytes
- type User
- type ValidationError
- type WebURL
- type WithdrawalRequest
Constants ¶
const ( // RunStatusUnstarted is the default state of any run status. RunStatusUnstarted = RunStatus("unstarted") // RunStatusInProgress is used for when a run is actively being executed. RunStatusInProgress = RunStatus("in_progress") // RunStatusPendingIncomingConfirmations is used for when a run is awaiting for incoming block confirmations // e.g. waiting for the log event to be N blocks deep RunStatusPendingIncomingConfirmations = RunStatus("pending_incoming_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") // RunStatusPendingOutgoingConfirmations is used for when a run is waiting for outgoing block confirmations // e.g. we have sent a transaction using ethtx and are now waiting for it to be N blocks deep RunStatusPendingOutgoingConfirmations = RunStatus("pending_outgoing_confirmations") // 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 ( ResultKey = "result" ResultCollectionKey = "__adamoracle_result_collection__" )
const ( EthTxUnstarted = EthTxState("unstarted") EthTxInProgress = EthTxState("in_progress") EthTxFatalError = EthTxState("fatal_error") EthTxUnconfirmed = EthTxState("unconfirmed") EthTxConfirmed = EthTxState("confirmed") EthTxConfirmedMissingReceipt = EthTxState("confirmed_missing_receipt") EthTxAttemptInProgress = EthTxAttemptState("in_progress") EthTxAttemptInsufficientEth = EthTxAttemptState("insufficient_eth") EthTxAttemptBroadcast = EthTxAttemptState("broadcast") )
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 FunctionSelectorLength = 4
FunctionSelectorLength should always be a length of 4 as a byte.
const (
MaxBcryptPasswordLength = 50
)
https://security.stackexchange.com/questions/39849/does-bcrypt-have-a-maximum-password-length
const ( // SignatureLength is the length of the signature in bytes: v = 1, r = 32, s // = 32; v + r + s = 65 SignatureLength = 65 )
Variables ¶
var ( // 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)") // RandomnessRequestLogTopic is the signature for the event log // VRFCoordinator.RandomnessRequest. RandomnessRequestLogTopic = VRFRandomnessRequestLogTopic() // 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] OracleFulfillmentFunctionID2020 = utils.MustHash("fulfillOracleRequest2(bytes32,uint256,address,bytes4,uint256,bytes)").Hex()[:10] )
var AdamoracleFulfilledTopic = utils.MustHash("AdamoracleFulfilled(bytes32)")
AdamoracleFulfilledTopic is the signature for the event emitted after calling AdamoracleClient.validateAdamoracleCallback(requestId). See ../../evm-contracts/src/v0.1/AdamoracleClient.sol
var CronParser cron.Parser
CronParser is the global parser for crontabs. It accepts the standard 5 field cron syntax as well as an optional 6th field at the front to represent seconds.
var LogBasedAdamoracleJobInitiators = []string{InitiatorRunLog, InitiatorEthLog, InitiatorRandomnessLog}
LogBasedAdamoracleJobInitiators are initiators which kick off a user-specified adamoracle job when an appropriate ethereum log is received. (InitiatorFluxMonitor kicks off work, but not a user-specified job.)
var NilJobID = JobID{}
NilJobID is special form of JobID that is specified to have all 128 bits set to zero.
var TopicsForInitiatorsWhichRequireJobSpecIDTopic = map[string][]common.Hash{ InitiatorRunLog: {RunLogTopic20190207withoutIndexes}, InitiatorRandomnessLog: {RandomnessRequestLogTopic}, }
topicsForInitiatorsWhichRequireJobSpecTopic are the log topics which kick off a user job with the given type of initiator. If adamoracle 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.
WeiPerEth is amount of Wei currency units in one Eth.
Functions ¶
func AuthenticateBridgeType ¶
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 ¶
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 ¶
AuthenticateUserByToken returns true on successful authentication of the user against the given Authentication Token.
func CoerceInterfaceMapToStringMap ¶
func CoerceInterfaceMapToStringMap(in interface{}) (interface{}, error)
CoerceInterfaceMapToStringMap converts map[interface{}]interface{} (interface maps) to map[string]interface{} (string maps) and []interface{} with interface maps to string maps. Relevant when serializing between CBOR and JSON.
It also handles the CBOR 'bignum' type as documented here: https://tools.ietf.org/html/rfc7049#section-2.4.2
func FilterQueryFactory ¶
func FilterQueryFactory(i Initiator, from *big.Int, addresses ...common.Address) (q ethereum.FilterQuery, err error)
FilterQueryFactory returns the ethereum FilterQuery for this initiator.
func HexToInt64 ¶
func HexToInt64(input interface{}) int64
HexToInt64 performs the inverse of Int64ToHex Returns 0 on invalid input
func IDToHexTopic ¶
IDToHexTopic encodes the string representation of the JobID
func IDToTopic ¶
IDToTopic encodes the bytes representation of the JobID padded to fit into a bytes32
func Int64ToHex ¶
Int64ToHex converts an int64 into go-ethereum's hex representation
func JobSpecIDTopics ¶
JobSpecIDTopics lists the ways jsID could be represented as a log topic. This allows log subscriptions to respond to all possible representations.
func MarshalBridgeMetaData ¶
func MarshalToMap ¶
MarshalToMap converts a struct (typically) to a map[string] so it can be manipulated without repeatedly serializing/deserializing
func NewBridgeType ¶
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 ¶
NewDatabaseAccessError returns a database access error.
func NewValidationError ¶
NewValidationError returns a validation error.
func ReceiptIndicatesRunLogFulfillment ¶
ReceiptIndicatesRunLogFulfillment returns true if this tx receipt is the result of a fulfilled run log.
func ReceiptIsUnconfirmed ¶
Unconfirmed returns true if the transaction is not confirmed.
func VRFCoordinatorABI ¶
VRFCoordinatorABI returns the ABI for the VRFCoordinator contract
func VRFFulfillMethod ¶
VRFFulfillMethod returns the golang abstraction of the fulfillRandomnessRequest method
func VRFFulfillSelector ¶
func VRFFulfillSelector() string
VRFFulfillSelector returns the signature of the fulfillRandomnessRequest method on the VRFCoordinator contract
func VRFRandomnessRequestLogTopic ¶
VRFRandomnessRequestLogTopic returns the signature of the RandomnessRequest log emitted by the VRFCoordinator contract
func ValidateBulkDeleteRunRequest ¶
func ValidateBulkDeleteRunRequest(request *BulkDeleteRunRequest) error
ValidateBulkDeleteRunRequest returns a task from a request to make a task
Types ¶
type AddressCollection ¶
AddressCollection is an array of common.Address serializable to and from a database.
func (*AddressCollection) Scan ¶
func (r *AddressCollection) Scan(value interface{}) error
Scan parses the database value as a string.
func (AddressCollection) ToStrings ¶
func (r AddressCollection) ToStrings() []string
ToStrings returns this address collection as an array of strings.
type AnyTime ¶
AnyTime holds a common field for time, and serializes it as a json number.
func (AnyTime) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this time is null.
func (AnyTime) MarshalText ¶
MarshalText returns null if not set, or the time.
func (*AnyTime) UnmarshalJSON ¶
UnmarshalJSON parses the raw time stored in JSON-encoded data and stores it to the Time field.
func (*AnyTime) UnmarshalText ¶
UnmarshalText parses null or a valid time.
type Block ¶
type Block struct { Number int64 Hash common.Hash ParentHash common.Hash Transactions []types.Transaction }
Block represents an ethereum block
func (Block) MarshalJSON ¶
MarshalJSON implements json marshalling for Block
func (*Block) UnmarshalJSON ¶
UnmarshalJSON unmarshals to a Block
type BridgeMetaData ¶
type BridgeMetaData struct { LatestAnswer *big.Int `json:"latestAnswer"` UpdatedAt *big.Int `json:"updatedAt"` // A unix timestamp }
NOTE: latestAnswer and updatedAt is the only metadata used. Currently market closer adapter and outlier detection depend latestAnswer. https://github.com/smartcontractkit/external-adapters-js/tree/f474bd2e2de13ebe5c9dc3df36ebb7018817005e/composite/market-closure https://github.com/smartcontractkit/external-adapters-js/tree/5abb8e5ec2024f724fd39122897baa63c3cd0167/composite/outlier-detection
type BridgeMetaDataJSON ¶
type BridgeMetaDataJSON struct {
Meta BridgeMetaData
}
type BridgeRunResult ¶
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 ¶
func (brr BridgeRunResult) GetError() error
GetError returns the error of a BridgeRunResult if it is present.
func (BridgeRunResult) HasError ¶
func (brr BridgeRunResult) HasError() bool
HasError returns true if the status is errored or the error message is set
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 `gorm:"primary_key"` URL WebURL Confirmations uint32 IncomingTokenHash string Salt string OutgoingToken string MinimumContractPayment *assets.Adam `gorm:"type:varchar(255)"` CreatedAt time.Time UpdatedAt time.Time }
BridgeType is used for external adapters and has fields for the name of the adapter and its URL.
type BridgeTypeAuthentication ¶
type BridgeTypeAuthentication struct { Name TaskType URL WebURL Confirmations uint32 IncomingToken string OutgoingToken string MinimumContractPayment *assets.Adam }
BridgeTypeAuthentication is the record returned in response to a request to create a BridgeType
type BridgeTypeRequest ¶
type BridgeTypeRequest struct { Name TaskType `json:"name"` URL WebURL `json:"url"` Confirmations uint32 `json:"confirmations"` MinimumContractPayment *assets.Adam `json:"minimumContractPayment"` }
BridgeTypeRequest is the incoming record used to create a BridgeType
func (BridgeTypeRequest) GetID ¶
func (bt BridgeTypeRequest) GetID() string
GetID returns the ID of this structure for jsonapi serialization.
func (BridgeTypeRequest) GetName ¶
func (bt BridgeTypeRequest) GetName() string
GetName returns the pluralized "type" of this structure for jsonapi serialization.
func (*BridgeTypeRequest) SetID ¶
func (bt *BridgeTypeRequest) SetID(value string) error
SetID is used to set the ID of this structure when deserializing from jsonapi documents.
type BulkDeleteRunRequest ¶
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 ¶
type ChangeAuthTokenRequest struct {
Password string `json:"password"`
}
Changeauth.TokenRequest is sent when updating a User's authentication token.
type Configuration ¶
type Configuration struct { ID int64 `gorm:"primary_key"` Name string `gorm:"not null;unique;index"` Value string `gorm:"not null"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *gorm.DeletedAt }
Configuration stores key value pairs for overriding global configuration
type CreateJobSpecRequest ¶
type CreateJobSpecRequest struct {
TOML string `json:"toml"`
}
CreateJobSpecRequest represents a request to create and start and OCR job spec.
type Cron ¶
type Cron string
Cron holds the string that will represent the spec of the cron-job.
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 Duration ¶
type Duration struct {
// contains filtered or unexported fields
}
Duration is a non-negative time duration.
func MustMakeDuration ¶
func (Duration) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Duration) 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 ¶
UnmarshalJSON implements the json.Unmarshaler interface.
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 EIP55AddressFromAddress ¶
func EIP55AddressFromAddress(a common.Address) (EIP55Address, error)
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) Hex ¶
func (a EIP55Address) Hex() string
Hex is idential to String but makes the API similar to common.Address
func (*EIP55Address) Scan ¶
func (a *EIP55Address) Scan(value interface{}) error
Scan reads the database value and returns an instance.
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 EIP55AddressCollection ¶
type EIP55AddressCollection []EIP55Address
EIP55AddressCollection is an array of EIP55Addresses.
func (*EIP55AddressCollection) Scan ¶
func (c *EIP55AddressCollection) Scan(value interface{}) error
Scan reads the database value and returns an instance.
type Encumbrance ¶
type Encumbrance struct { // Corresponds to requestDigest in solidity ServiceAgreement struct ID int64 `json:"-" gorm:"primary_key;auto_increment"` // Price to request a report based on this agreement Payment *assets.Adam `json:"payment,omitempty"` // 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 FunctionSelector `json:"aggInitiateJobSelector" gorm:"not null"` // selector for fulfillment (oracle reporting) method on aggregator contract AggFulfillSelector FunctionSelector `json:"aggFulfillSelector" gorm:"not null"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` }
Encumbrance connects job specifications with on-chain encumbrances.
func (Encumbrance) ABI ¶
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 ¶
type EthLogEvent struct {
InitiatorLogEvent
}
EthLogEvent provides functionality specific to a log event emitted for an eth log initiator.
type EthReceipt ¶
type EthTx ¶
type EthTx struct { ID int64 Nonce *int64 FromAddress common.Address ToAddress common.Address EncodedPayload []byte Value assets.Eth GasLimit uint64 Error *string // BroadcastAt is updated every time an attempt for this eth_tx is re-sent // In almost all cases it will be within a second or so of the actual send time. BroadcastAt *time.Time CreatedAt time.Time State EthTxState EthTxAttempts []EthTxAttempt `gorm:"->"` }
type EthTxAttempt ¶
type EthTxAttempt struct { ID int64 EthTxID int64 EthTx EthTx GasPrice utils.Big SignedRawTx []byte Hash common.Hash CreatedAt time.Time BroadcastBeforeBlockNum *int64 State EthTxAttemptState EthReceipts []EthReceipt `gorm:"foreignKey:TxHash;references:Hash;association_foreignkey:Hash;->"` }
func (EthTxAttempt) GetSignedTx ¶
func (a EthTxAttempt) GetSignedTx() (*types.Transaction, error)
GetSignedTx decodes the SignedRawTx into a types.Transaction struct
type EthTxAttemptState ¶
type EthTxAttemptState string
type EthTxState ¶
type EthTxState string
type ExternalInitiator ¶
type ExternalInitiator struct { ID int64 `gorm:"primary_key"` 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 ¶
func NewExternalInitiator( eia *auth.Token, eir *ExternalInitiatorRequest, ) (*ExternalInitiator, error)
NewExternalInitiator generates an ExternalInitiator from an auth.Token, hashing the password for storage
type ExternalInitiatorRequest ¶
type ExternalInitiatorRequest struct { Name string `json:"name"` URL *WebURL `json:"url,omitempty"` }
ExternalInitiatorRequest is the incoming record used to create an ExternalInitiator.
type Feeds ¶
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 FluxMonitorRoundStats ¶
type FluxMonitorRoundStats struct { ID uint64 `gorm:"primary key;not null;auto_increment"` JobRunID uuid.NullUUID `gorm:"default:null;foreignkey:JobRunID"` Aggregator common.Address `gorm:"not null"` RoundID uint32 `gorm:"not null"` NumNewRoundLogs uint64 `gorm:"not null;default 0"` NumSubmissions uint64 `gorm:"not null;default 0"` }
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) Bytes ¶
func (f FunctionSelector) Bytes() []byte
Bytes returns the FunctionSelector as a byte slice
func (FunctionSelector) MarshalJSON ¶
func (f FunctionSelector) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of f
func (*FunctionSelector) Scan ¶
func (f *FunctionSelector) Scan(value interface{}) error
Scan returns the selector from its serialization in the database
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.
type Head ¶
type Head struct { ID uint64 Hash common.Hash Number int64 ParentHash common.Hash Parent *Head `gorm:"-"` Timestamp time.Time CreatedAt time.Time }
Head represents a BlockNumber, BlockHash.
func (Head) ChainHashes ¶
ChainHashes returns an array of block hashes by recursively looking up parents
func (Head) ChainLength ¶
ChainLength returns the length of the chain followed by recursively looking up parents
func (Head) EarliestInChain ¶
EarliestInChain recurses through parents until it finds the earliest one
func (*Head) GreaterThan ¶
GreaterThan compares BlockNumbers and returns true if the receiver BlockNumber is greater than the supplied BlockNumber
func (Head) HashAtHeight ¶
HashAtHeight returns the hash of the block at the given heigh, if it is in the chain. If not in chain, returns the zero hash
func (Head) IsInChain ¶
IsInChain returns true if the given hash matches the hash of a head in the chain
func (*Head) MarshalJSON ¶
func (*Head) NextInt ¶
NextInt returns the next BlockNumber as big.int, or nil if nil to represent latest.
func (*Head) UnmarshalJSON ¶
type IdleTimerConfig ¶
type IdleTimerConfig struct { Disabled bool `json:"disabled,omitempty"` Duration Duration `json:"duration,omitempty"` }
func (*IdleTimerConfig) Scan ¶
func (itc *IdleTimerConfig) Scan(value interface{}) error
Scan is defined so that we can read IdleTimerConfig as JSONB, because of an error with GORM where it has trouble with nested structs as JSONB. See https://github.com/jinzhu/gorm/issues/2704
func (IdleTimerConfig) Value ¶
func (itc IdleTimerConfig) Value() (driver.Value, error)
Value is defined so that we can store IdleTimerConfig as JSONB, because of an error with GORM where it has trouble with nested structs as JSONB. See https://github.com/jinzhu/gorm/issues/2704
type Initiator ¶
type Initiator struct { ID int64 `json:"id" gorm:"primary_key;auto_increment"` JobSpecID JobID `json:"jobSpecId"` // 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 gorm.DeletedAt `json:"-" gorm:"index"` UpdatedAt time.Time `json:"-"` }
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 ¶
func NewInitiatorFromRequest( initr InitiatorRequest, jobSpec JobSpec, ) Initiator
NewInitiatorFromRequest creates an Initiator from the corresponding parameters in a InitiatorRequest
func (Initiator) IsLogInitiated ¶
IsLogInitiated Returns true if triggered by event logs.
type InitiatorLogEvent ¶
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 ¶
func (le InitiatorLogEvent) BlockNumber() *big.Int
BlockNumber returns the block number for the given InitiatorSubscriptionLogEvent.
func (InitiatorLogEvent) ForLogger ¶
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 ¶
func (le InitiatorLogEvent) GetInitiator() Initiator
GetInitiator returns the initiator.
func (InitiatorLogEvent) GetJobSpecID ¶
func (le InitiatorLogEvent) GetJobSpecID() JobID
GetJobSpecID returns the associated JobSpecID
func (InitiatorLogEvent) GetLog ¶
func (le InitiatorLogEvent) GetLog() types.Log
GetLog returns the log.
func (InitiatorLogEvent) JSON ¶
func (le InitiatorLogEvent) JSON() (JSON, error)
JSON returns the eth log as JSON.
func (InitiatorLogEvent) LogRequest ¶
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 ¶
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 ¶
func (le InitiatorLogEvent) ToDebug()
ToDebug prints this event via logger.Debug.
func (InitiatorLogEvent) Validate ¶
func (le InitiatorLogEvent) Validate() bool
Validate returns true, no validation on this log event type.
func (InitiatorLogEvent) ValidateRequester ¶
func (le InitiatorLogEvent) ValidateRequester() error
ValidateRequester returns true since all requests are valid for base initiator log events.
type InitiatorParams ¶
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"` // JobIDTopicFilter, if present, is used in addition to the job's actual ID when filtering // initiator logs JobIDTopicFilter JobID `json:"jobIDTopicFilter,omitempty"` RequestData JSON `json:"requestData,omitempty" gorm:"type:text"` Feeds Feeds `json:"feeds,omitempty" gorm:"type:text"` Precision int32 `json:"precision,omitempty" gorm:"type:smallint"` Threshold float32 `json:"threshold,omitempty"` // AbsoluteThreshold is the maximum absolute change allowed in a fluxmonitored // value before a new round should be kicked off, so that the current value // can be reported on-chain. AbsoluteThreshold float32 `json:"absoluteThreshold" gorm:"type:float;not null"` PollTimer PollTimerConfig `json:"pollTimer,omitempty" gorm:"type:jsonb"` IdleTimer IdleTimerConfig `json:"idleTimer,omitempty" gorm:"type:jsonb"` }
InitiatorParams is a collection of the possible parameters that different Initiators may require.
type InitiatorRequest ¶
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 Interval ¶
Interval represents a time.Duration stored as a Postgres interval type
func (Interval) MarshalText ¶
MarshalText implements the text.Marshaler interface.
func (*Interval) UnmarshalText ¶
UnmarshalText implements the text.Unmarshaler interface.
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 ParseRunLog ¶
ParseRunLog decodes the CBOR in the ABI of the log event.
func (JSON) GormDBDataType ¶
GormDBDataType gorm db data type
func (JSON) GormDataType ¶
func (JSON) MarshalJSON ¶
MarshalJSON returns the JSON data if it already exists, returns an empty JSON object as bytes if not.
func (JSON) PrependAtArrayKey ¶
func (*JSON) UnmarshalJSON ¶
UnmarshalJSON parses the JSON bytes and stores in the *JSON pointer.
func (*JSON) UnmarshalTOML ¶
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 JobID ¶
JobID is a UUID that has a custom display format
func NewIDFromString ¶
NewIDFromString is a convenience function to return an id from an input string
func (JobID) MarshalText ¶
MarshalText implements encoding.TextMarshaler, using String()
func (JobID) String ¶
String satisfies the Stringer interface and removes all '-'s from the string representation of the uuid
func (*JobID) UnmarshalString ¶
UnmarshalString is a wrapper for UnmarshalText which takes a string
func (*JobID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type JobRun ¶
type JobRun struct { ID uuid.UUID `json:"id" gorm:"type:uuid;primary_key;not null"` JobSpecID JobID `json:"jobId" gorm:"type:uuid"` Result RunResult `json:"result" gorm:"foreignkey:ResultID"` ResultID clnull.Int64 `json:"-"` RunRequest RunRequest `json:"-" gorm:"foreignkey:RunRequestID"` RunRequestID clnull.Int64 `json:"-"` Status RunStatus `json:"status" gorm:"default:'unstarted'"` TaskRuns []TaskRun `json:"taskRuns" gorm:"foreignKey:JobRunID"` CreatedAt time.Time `json:"createdAt"` FinishedAt null.Time `json:"finishedAt"` UpdatedAt time.Time `json:"updatedAt"` Initiator Initiator `json:"initiator" gorm:"foreignkey:InitiatorID;->"` InitiatorID int64 `json:"-"` CreationHeight *utils.Big `json:"creationHeight"` ObservedHeight *utils.Big `json:"observedHeight"` DeletedAt gorm.DeletedAt `json:"-"` Payment *assets.Adam `json:"payment,omitempty"` }
JobRun tracks the status of a job by holding its TaskRuns and the Result of each Run.
func MakeJobRun ¶
func MakeJobRun(job *JobSpec, now time.Time, initiator *Initiator, currentHeight *big.Int, runRequest *RunRequest) JobRun
MakeJobRun returns a new JobRun copy
func (*JobRun) ApplyBridgeRunResult ¶
func (jr *JobRun) ApplyBridgeRunResult(result BridgeRunResult)
ApplyBridgeRunResult saves the input from a BridgeAdapter
func (*JobRun) ApplyOutput ¶
ApplyOutput updates the JobRun's Result and Status
func (*JobRun) Cancel ¶
func (jr *JobRun) Cancel()
Cancel sets this run as cancelled, it should no longer be processed.
func (*JobRun) ErrorString ¶
ErrorString returns the error as a string if present, otherwise "".
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) NextTaskRun ¶
NextTaskRun returns the next immediate TaskRun in the list of unfinished TaskRuns.
func (*JobRun) NextTaskRunIndex ¶
NextTaskRunIndex returns the position of the next unfinished task
func (*JobRun) PreviousTaskRun ¶
PreviousTaskRun returns the last task to be processed, if it exists
func (*JobRun) SetID ¶
SetID is used to set the ID of this structure when deserializing from jsonapi documents.
func (*JobRun) TasksRemain ¶
TasksRemain returns true if there are unfinished tasks left for this job run
type JobSpec ¶
type JobSpec struct { ID JobID `json:"id,omitempty" gorm:"primary_key;not null"` Name string `json:"name"` CreatedAt time.Time `json:"createdAt" gorm:"index"` Initiators []Initiator `json:"initiators"` MinPayment *assets.Adam `json:"minPayment,omitempty"` Tasks []TaskSpec `json:"tasks"` StartAt null.Time `json:"startAt" gorm:"index"` EndAt null.Time `json:"endAt" gorm:"index"` DeletedAt gorm.DeletedAt `json:"-" gorm:"index"` UpdatedAt time.Time `json:"-"` Errors []JobSpecError `json:"-" gorm:"foreignkey:JobSpecID;->"` }
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 NewJobFromRequest ¶
func NewJobFromRequest(jsr JobSpecRequest) JobSpec
NewJobFromRequest creates a JobSpec from the corresponding parameters in a JobSpecRequest
func (JobSpec) GetName ¶
GetName returns the pluralized "type" of this structure for jsonapi serialization.
func (JobSpec) InitiatorExternal ¶
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 ¶
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.
type JobSpecError ¶
type JobSpecError struct { ID int64 `json:"id"` JobSpecID JobID `json:"-"` Description string `json:"description"` Occurrences uint `json:"occurrences"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` }
JobSpecError represents an asynchronous error caused by a JobSpec
func NewJobSpecError ¶
func NewJobSpecError(jobSpecID JobID, description string) JobSpecError
NewJobSpecError creates a new JobSpecError struct
type JobSpecRequest ¶
type JobSpecRequest struct { Name string `json:"name"` Initiators []InitiatorRequest `json:"initiators"` Tasks []TaskSpecRequest `json:"tasks"` StartAt null.Time `json:"startAt"` EndAt null.Time `json:"endAt"` MinPayment *assets.Adam `json:"minPayment,omitempty"` }
JobSpecRequest represents a schema for the incoming job spec request as used by the API.
type KV ¶
type KV map[string]interface{}
KV represents a key/value pair to be added to a JSON object
type Key ¶
type Key struct { ID int32 `gorm:"primary_key"` Address EIP55Address JSON JSON CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt // This is the nonce that should be used for the next transaction. // Conceptually equivalent to geth's `PendingNonceAt` but more reliable // because we have a better view of our own transactions NextNonce int64 // LastUsed is the time that the address was last assigned to a transaction LastUsed *time.Time // IsFunding marks the address as being used for rescuing the node and the pending transactions // Only one key can be IsFunding=true at a time. IsFunding bool }
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 ¶
NewKeyFromFile creates an instance in memory from a key file on disk.
func (*Key) WriteToDisk ¶
WriteToDisk writes this key to disk at the passed path.
type LogRequest ¶
type LogRequest interface { GetLog() types.Log GetJobSpecID() JobID 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, OracleLogEvent
type NodeVersion ¶
func NewNodeVersion ¶
func NewNodeVersion(version string) NodeVersion
type NullSigner ¶
type NullSigner struct{}
type PeerID ¶
func (PeerID) MarshalJSON ¶
func (*PeerID) UnmarshalJSON ¶
func (*PeerID) UnmarshalText ¶
type PollTimerConfig ¶
type PollTimerConfig struct { Disabled bool `json:"disabled,omitempty"` Period Duration `json:"period,omitempty"` }
func (*PollTimerConfig) Scan ¶
func (ptc *PollTimerConfig) Scan(value interface{}) error
Scan is defined so that we can read PollTimerConfig as JSONB, because of an error with GORM where it has trouble with nested structs as JSONB. See https://github.com/jinzhu/gorm/issues/2704
func (PollTimerConfig) Value ¶
func (ptc PollTimerConfig) Value() (driver.Value, error)
Value is defined so that we can store PollTimerConfig as JSONB, because of an error with GORM where it has trouble with nested structs as JSONB. See https://github.com/jinzhu/gorm/issues/2704
type RandomnessLogEvent ¶
type RandomnessLogEvent struct{ InitiatorLogEvent }
RandomnessLogEvent provides functionality specific to a log event emitted for a run log initiator.
func (RandomnessLogEvent) JSON ¶
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 ¶
func (le RandomnessLogEvent) Requester() common.Address
Requester pulls the requesting address out of the LogEvent's topics.
func (RandomnessLogEvent) RunRequest ¶
func (le RandomnessLogEvent) RunRequest() (RunRequest, error)
RunRequest returns a RunRequest instance with all parameters from a run log topic, like RequestID.
func (RandomnessLogEvent) Validate ¶
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 ¶
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 RandomnessRequestLog ¶
type RandomnessRequestLog struct { KeyHash common.Hash Seed *big.Int // uint256 JobID common.Hash Sender common.Address Fee *assets.Adam // uint256 RequestID common.Hash Raw RawRandomnessRequestLog }
RandomnessRequestLog contains the data for a RandomnessRequest log, represented as compatible golang types.
func ParseRandomnessRequestLog ¶
func ParseRandomnessRequestLog(log types.Log) (*RandomnessRequestLog, error)
ParseRandomnessRequestLog returns the RandomnessRequestLog corresponding to the raw logData
func RawRandomnessRequestLogToRandomnessRequestLog ¶
func RawRandomnessRequestLogToRandomnessRequestLog( l *RawRandomnessRequestLog) *RandomnessRequestLog
func (*RandomnessRequestLog) ComputedRequestID ¶
func (l *RandomnessRequestLog) ComputedRequestID() common.Hash
func (*RandomnessRequestLog) Equal ¶
func (l *RandomnessRequestLog) Equal(ol RandomnessRequestLog) bool
Equal(ol) is true iff l is the same log as ol, and both represent valid RandomnessRequest logs.
func (*RandomnessRequestLog) RawData ¶
func (l *RandomnessRequestLog) RawData() ([]byte, error)
RawData returns the raw bytes corresponding to l in a solidity log
This serialization does not include the JobID, because that's an indexed field.
type RawRandomnessRequestLog ¶
type RawRandomnessRequestLog solidity_vrf_coordinator_interface.VRFCoordinatorRandomnessRequest
RawRandomnessRequestLog is used to parse a RandomnessRequest log into types go-ethereum knows about.
type RunInput ¶
type RunInput struct {
// contains filtered or unexported fields
}
RunInput represents the input for performing a Task
func NewRunInput ¶
NewRunInput creates a new RunInput with arbitrary data
func NewRunInputWithResult ¶
func NewRunInputWithResult(jobRunID uuid.UUID, taskRunID uuid.UUID, value interface{}, status RunStatus) *RunInput
NewRunInputWithResult creates a new RunInput with a value in the "result" field
func (RunInput) CloneWithData ¶
func (RunInput) ResultCollection ¶
func (RunInput) ResultString ¶
ResultString returns the string result of the Data JSON field.
type RunLogEvent ¶
type RunLogEvent struct {
InitiatorLogEvent
}
RunLogEvent provides functionality specific to a log event emitted for a run log initiator.
func (RunLogEvent) JSON ¶
func (le RunLogEvent) JSON() (JSON, error)
JSON decodes the RunLogEvent's data converts it to a JSON object.
func (RunLogEvent) Requester ¶
func (le RunLogEvent) Requester() (common.Address, error)
Requester pulls the requesting address out of the LogEvent's topics.
func (RunLogEvent) RunRequest ¶
func (le RunLogEvent) RunRequest() (RunRequest, error)
RunRequest returns an RunRequest instance with all parameters from a run log topic, like RequestID.
func (RunLogEvent) Validate ¶
func (le RunLogEvent) Validate() bool
Validate returns whether or not the contained log has a properly encoded job id.
func (RunLogEvent) ValidateRequester ¶
func (le RunLogEvent) ValidateRequester() error
ValidateRequester returns true if the requester matches the one associated with the initiator.
type RunOutput ¶
type RunOutput struct {
// contains filtered or unexported fields
}
RunOutput represents the result of performing a Task
func NewRunOutputComplete ¶
NewRunOutputComplete returns a new RunOutput that is complete and contains raw data
func NewRunOutputCompleteWithResult ¶
NewRunOutputCompleteWithResult returns a new RunOutput that is complete and contains a result and preserves the resultCollection.
func NewRunOutputError ¶
NewRunOutputError returns a new RunOutput with an error
func NewRunOutputInProgress ¶
NewRunOutputInProgress returns a new RunOutput that indicates the task is still in progress
func NewRunOutputPendingBridge ¶
func NewRunOutputPendingBridge() RunOutput
NewRunOutputPendingBridge returns a new RunOutput that indicates the task is still in progress
func NewRunOutputPendingConnection ¶
func NewRunOutputPendingConnection() RunOutput
NewRunOutputPendingConnection returns a new RunOutput that indicates the task got disconnected
func NewRunOutputPendingConnectionWithData ¶
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 NewRunOutputPendingOutgoingConfirmationsWithData ¶
NewRunOutputPendingOutgoingConfirmationsWithData returns a new RunOutput that indicates the task is pending outgoing confirmations but also has some data that needs to be fed in on next invocation
func (RunOutput) HasError ¶
HasError returns true if the status is errored or the error message is set
func (RunOutput) ResultCollection ¶
type RunRequest ¶
type RunRequest struct { ID int64 `gorm:"primary_key"` RequestID *common.Hash TxHash *common.Hash BlockHash *common.Hash Requester *common.Address CreatedAt time.Time Payment *assets.Adam RequestParams JSON `gorm:"type:jsonb;default:'{}'"` }
RunRequest stores the fields used to initiate the parent job run.
func NewRunRequest ¶
func NewRunRequest(requestParams JSON) *RunRequest
NewRunRequest returns a new RunRequest instance.
type RunResult ¶
type RunResult struct { ID int64 `json:"-" gorm:"primary_key;auto_increment"` Data JSON `json:"data"` ErrorMessage null.String `json:"error"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` }
RunResult keeps track of the outcome of a TaskRun or JobRun. It stores the Data and ErrorMessage.
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) PendingConnection ¶
PendingConnection returns true if the status is pending_connection.
func (RunStatus) PendingIncomingConfirmations ¶
PendingIncomingConfirmations returns true if the status is pending_incoming_confirmations.
func (RunStatus) PendingOutgoingConfirmations ¶
PendingOutgoingConfirmations returns true if the status is pending_incoming_confirmations.
func (RunStatus) PendingSleep ¶
PendingSleep returns true if the status is pending_sleep.
type RunStatusCollection ¶
type RunStatusCollection []RunStatus
RunStatusCollection is an array of RunStatus.
func (*RunStatusCollection) Scan ¶
func (r *RunStatusCollection) Scan(value interface{}) error
Scan reads the database value and returns an instance.
func (RunStatusCollection) ToStrings ¶
func (r RunStatusCollection) ToStrings() []string
ToStrings returns a copy of RunStatusCollection as an array of strings.
type SendEtherRequest ¶
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 ¶
type ServiceAgreement struct { ID string `json:"id" gorm:"primary_key"` CreatedAt time.Time `json:"createdAt" gorm:"index"` Encumbrance Encumbrance `json:"encumbrance"` EncumbranceID int64 `json:"-"` RequestBody string `json:"requestBody"` Signature Signature `json:"signature" gorm:"type:varchar(255)"` JobSpec JobSpec `gorm:"foreignkey:JobSpecID"` JobSpecID JobID `json:"jobSpecId"` UpdatedAt time.Time `json:"-"` }
ServiceAgreement connects job specifications with on-chain encumbrances.
func BuildServiceAgreement ¶
func BuildServiceAgreement(us UnsignedServiceAgreement, signer Signer) (ServiceAgreement, error)
BuildServiceAgreement builds a signed service agreement
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 { Initiators []InitiatorRequest `json:"initiators"` Tasks []TaskSpecRequest `json:"tasks"` Payment *assets.Adam `json:"payment,omitempty"` Expiration uint64 `json:"expiration"` EndAt AnyTime `json:"endAt"` Oracles EIP55AddressCollection `json:"oracles"` Aggregator EIP55Address `json:"aggregator"` AggInitiateJobSelector FunctionSelector `json:"aggInitiateJobSelector"` AggFulfillSelector FunctionSelector `json:"aggFulfillSelector"` StartAt AnyTime `json:"startAt"` }
ServiceAgreementRequest encodes external ServiceAgreement json representation.
type Session ¶
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 ¶
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 Sha256Hash ¶
type Sha256Hash [32]byte
Explicit type indicating a 32-byte sha256 hash
func MustSha256HashFromHex ¶
func MustSha256HashFromHex(x string) Sha256Hash
func Sha256HashFromHex ¶
func Sha256HashFromHex(x string) (Sha256Hash, error)
func (Sha256Hash) MarshalJSON ¶
func (s Sha256Hash) MarshalJSON() ([]byte, error)
MarshalJSON converts a Sha256Hash to a JSON byte slice.
func (*Sha256Hash) Scan ¶
func (s *Sha256Hash) Scan(value interface{}) error
func (Sha256Hash) String ¶
func (s Sha256Hash) String() string
func (*Sha256Hash) UnmarshalJSON ¶
func (s *Sha256Hash) UnmarshalJSON(input []byte) error
UnmarshalJSON converts a bytes slice of JSON to a TaskType.
func (*Sha256Hash) UnmarshalText ¶
func (s *Sha256Hash) UnmarshalText(bs []byte) error
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 SyncEvent ¶
type SyncEvent struct { ID int64 `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 ¶
type TaskRun struct { ID uuid.UUID `json:"id" gorm:"type:uuid;primary_key;not null"` JobRunID uuid.UUID `json:"-" gorm:"type:uuid"` Result RunResult `json:"result"` ResultID clnull.Int64 `json:"-"` Status RunStatus `json:"status" gorm:"default:'unstarted'"` TaskSpec TaskSpec `json:"task" gorm:"->"` TaskSpecID int64 `json:"-"` MinRequiredIncomingConfirmations clnull.Uint32 `json:"minimumConfirmations" gorm:"column:minimum_confirmations"` ObservedIncomingConfirmations clnull.Uint32 `json:"confirmations" gorm:"column:confirmations"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` }
TaskRun stores the Task and represents the status of the Task to be ran.
func (*TaskRun) ApplyBridgeRunResult ¶
func (tr *TaskRun) ApplyBridgeRunResult(result BridgeRunResult)
ApplyBridgeRunResult updates the TaskRun's Result and Status
func (*TaskRun) ApplyOutput ¶
ApplyOutput updates the TaskRun's Result and Status
type TaskSpec ¶
type TaskSpec struct { ID int64 `gorm:"primary_key"` JobSpecID JobID `json:"-"` Type TaskType `json:"type" gorm:"index;not null"` MinRequiredIncomingConfirmations clnull.Uint32 `json:"confirmations" gorm:"column:confirmations"` Params JSON `json:"params" gorm:"type:text"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt }
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 ¶
type TaskSpecRequest struct { Type TaskType `json:"type"` MinRequiredIncomingConfirmations clnull.Uint32 `json:"confirmations"` Params JSON `json:"params"` }
TaskSpecRequest represents a schema for incoming TaskSpec requests as used by the API.
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 Topics ¶
Topics handle the serialization of ethereum log topics to and from the data store.
type UnsignedServiceAgreement ¶
type UnsignedServiceAgreement struct { Encumbrance Encumbrance ID common.Hash RequestBody string JobSpecRequest JobSpecRequest }
UnsignedServiceAgreement contains the information to sign a service agreement
func NewUnsignedServiceAgreementFromRequest ¶
func NewUnsignedServiceAgreementFromRequest(reader io.Reader) (UnsignedServiceAgreement, error)
NewUnsignedServiceAgreementFromRequest builds the information required to sign a service agreement
type UntrustedBytes ¶
type UntrustedBytes []byte
This data can contain anything and is submitted by user on-chain, so we must be extra careful how we interact with it
func (UntrustedBytes) SafeByteSlice ¶
func (ary UntrustedBytes) SafeByteSlice(start int, end int) ([]byte, error)
SafeByteSlice returns an error on out of bounds access to a byte array, where a normal slice would panic instead
type User ¶
type User struct { Email string `gorm:"primary_key"` HashedPassword string CreatedAt time.Time `gorm:"index"` TokenKey string TokenSalt string TokenHashedSecret string UpdatedAt time.Time }
User holds the credentials for API user.
func (*User) DeleteAuthToken ¶
func (u *User) DeleteAuthToken()
DeleteAuthToken clears and disables the users Authentication Token.
func (*User) GenerateAuthToken ¶
GenerateAuthToken randomly generates and sets the users Authentication Token.
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) UnmarshalJSON ¶
UnmarshalJSON parses the raw URL stored in JSON-encoded data to a URL structure and sets it to the URL field.
Source 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
- flux_monitor.go
- job_id.go
- job_run.go
- job_spec.go
- job_spec_error.go
- key.go
- log_events.go
- node_version.go
- parse_randomness_request.go
- peer_id.go
- randomness_log_event.go
- run_input.go
- run_output.go
- service_agreement.go
- signature.go
- sync_events.go
- user.go
- vrf_coordinator_abi_values.go
- vrf_coordinator_interface.go