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

package orm

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

Index

Package Files

config.go config_reader.go locking_strategies.go log_wrapper.go orm.go schema.go

Constants

const BatchSize = 100

BatchSize is the safe number of records to cache during Batch calls for SQLite without causing load problems. NOTE: Now we no longer support SQLite, perhaps this can be tuned?

Variables

var (
    // ErrorNotFound is returned when finding a single value fails.
    ErrorNotFound = gorm.ErrRecordNotFound
    ErrorConflict = errors.New("record already exists")
)
var (
    ErrNoAdvisoryLock    = errors.New("can't acquire advisory lock")
    ErrReleaseLockFailed = errors.New("advisory lock release failed")
)
var OptimisticUpdateConflictError = errors.New("conflict while updating record")

OptimisticUpdateConflictError is returned when a record update failed because another update occurred while the model was in memory and the differences must be reconciled.

func Batch Uses

func Batch(chunkSize uint, cb func(offset, limit uint) (uint, error)) error

Batch is an iterator _like_ for batches of records

func EnvVarName Uses

func EnvVarName(field string) string

EnvVarName gets the environment variable name for a config schema field

type Config Uses

type Config struct {
    SecretGenerator SecretGenerator
    // contains filtered or unexported fields
}

Config holds parameters used by the application which can be overridden by setting environment variables.

If you add an entry here which does not contain sensitive information, you should also update presenters.ConfigWhitelist and cmd_test.TestClient_RunNodeShowsEnv.

func NewConfig Uses

func NewConfig() *Config

NewConfig returns the config with the environment variables set to their respective fields, or their defaults if environment variables are not set.

func (Config) AllowOrigins Uses

func (c Config) AllowOrigins() string

AllowOrigins returns the CORS hosts used by the frontend.

func (Config) BridgeResponseURL Uses

func (c Config) BridgeResponseURL() *url.URL

BridgeResponseURL represents the URL for bridges to send a response to.

func (Config) CertFile Uses

func (c Config) CertFile() string

CertFile returns the path where the server certificate is kept

func (Config) ChainID Uses

func (c Config) ChainID() *big.Int

ChainID represents the chain ID to use for transactions.

func (Config) ClientNodeURL Uses

func (c Config) ClientNodeURL() string

ClientNodeURL is the URL of the Ethereum node this Chainlink node should connect to.

func (Config) CreateProductionLogger Uses

func (c Config) CreateProductionLogger() *zap.Logger

CreateProductionLogger returns a custom logger for the config's root directory and LogLevel, with pretty printing for stdout. If LOG_TO_DISK is false, the logger will only log to stdout.

func (Config) DatabaseTimeout Uses

func (c Config) DatabaseTimeout() time.Duration

DatabaseTimeout represents how long to tolerate non response from the DB.

func (Config) DatabaseURL Uses

func (c Config) DatabaseURL() string

DatabaseURL configures the URL for chainlink to connect to. This must be a properly formatted URL, with a valid scheme (postgres://)

func (Config) DefaultHTTPLimit Uses

func (c Config) DefaultHTTPLimit() int64

DefaultHTTPLimit defines the limit for HTTP requests.

func (Config) DefaultHTTPTimeout Uses

func (c Config) DefaultHTTPTimeout() time.Duration

DefaultHTTPTimeout defines the default timeout for http requests

func (Config) DefaultMaxHTTPAttempts Uses

func (c Config) DefaultMaxHTTPAttempts() uint

DefaultMaxHTTPAttempts defines the limit for HTTP requests.

func (Config) Dev Uses

func (c Config) Dev() bool

Dev configures "development" mode for chainlink.

func (Config) EnableExperimentalAdapters Uses

func (c Config) EnableExperimentalAdapters() bool

EnableExperimentalAdapters enables support for experimental adapters

func (Config) EthGasBumpPercent Uses

func (c Config) EthGasBumpPercent() uint16

EthGasBumpPercent is the minimum percentage by which gas is bumped on each transaction attempt Change with care since values below geth's default will fail with "underpriced replacement transaction"

func (Config) EthGasBumpThreshold Uses

func (c Config) EthGasBumpThreshold() uint64

EthGasBumpThreshold is the number of blocks to wait for confirmations before bumping gas again

func (Config) EthGasBumpWei Uses

func (c Config) EthGasBumpWei() *big.Int

EthGasBumpWei is the minimum fixed amount of wei by which gas is bumped on each transaction attempt

func (Config) EthGasLimitDefault Uses

func (c Config) EthGasLimitDefault() uint64

EthGasLimitDefault sets the default gas limit for outgoing transactions.

func (Config) EthGasPriceDefault Uses

func (c Config) EthGasPriceDefault() *big.Int

EthGasPriceDefault is the starting gas price for every transaction

func (Config) EthMaxGasPriceWei Uses

func (c Config) EthMaxGasPriceWei() *big.Int

EthMaxGasPriceWei is the maximum amount in Wei that a transaction will be bumped to before abandoning it and marking it as errored.

func (Config) EthereumURL Uses

func (c Config) EthereumURL() string

EthereumURL represents the URL of the Ethereum node to connect Chainlink to.

func (Config) ExplorerAccessKey Uses

func (c Config) ExplorerAccessKey() string

ExplorerAccessKey returns the access key for authenticating with explorer

func (Config) ExplorerSecret Uses

func (c Config) ExplorerSecret() string

ExplorerSecret returns the secret for authenticating with explorer

func (Config) ExplorerURL Uses

func (c Config) ExplorerURL() *url.URL

ExplorerURL returns the websocket URL for this node to push stats to, or nil.

func (Config) FeatureExternalInitiators Uses

func (c Config) FeatureExternalInitiators() bool

FeatureExternalInitiators enables the External Initiator feature.

func (Config) FeatureFluxMonitor Uses

func (c Config) FeatureFluxMonitor() bool

FeatureFluxMonitor enables the Flux Monitor feature.

func (Config) GasUpdaterBlockDelay Uses

func (c Config) GasUpdaterBlockDelay() uint16

GasUpdaterBlockDelay is the number of blocks that the gas updater trails behind head. E.g. if this is set to 3, and we receive block 10, gas updater will fetch block 7. CAUTION: You might be tempted to set this to 0 to use the latest possible block, but it is possible to receive a head BEFORE that block is actually available from the connected node via RPC. In this case you will get false "zero" blocks that are missing transactions.

func (Config) GasUpdaterBlockHistorySize Uses

func (c Config) GasUpdaterBlockHistorySize() uint16

GasUpdaterBlockHistorySize is the number of past blocks to keep in memory to use as a basis for calculating a percentile gas price

func (Config) GasUpdaterEnabled Uses

func (c Config) GasUpdaterEnabled() bool

GasUpdaterEnabled turns on the automatic gas updater if set to true It is disabled by default

func (Config) GasUpdaterTransactionPercentile Uses

func (c Config) GasUpdaterTransactionPercentile() uint16

GasUpdaterTransactionPercentile is the percentile gas price to choose. E.g. if the past transaction history contains four transactions with gas prices: [100, 200, 300, 400], picking 25 for this number will give a value of 200

func (Config) JSONConsole Uses

func (c Config) JSONConsole() bool

JSONConsole enables the JSON console.

func (Config) KeyFile Uses

func (c Config) KeyFile() string

KeyFile returns the path where the server key is kept

func (Config) KeysDir Uses

func (c Config) KeysDir() string

KeysDir returns the path of the keys directory (used for keystore files).

func (Config) LinkContractAddress Uses

func (c Config) LinkContractAddress() string

LinkContractAddress represents the address

func (Config) LogLevel Uses

func (c Config) LogLevel() LogLevel

LogLevel represents the maximum level of log messages to output.

func (Config) LogSQLMigrations Uses

func (c Config) LogSQLMigrations() bool

LogSQLMigrations tells chainlink to log all SQL migrations made using the default logger

func (Config) LogSQLStatements Uses

func (c Config) LogSQLStatements() bool

LogSQLStatements tells chainlink to log all SQL statements made using the default logger

func (Config) LogToDisk Uses

func (c Config) LogToDisk() bool

LogToDisk configures disk preservation of logs.

func (Config) MaxRPCCallsPerSecond Uses

func (c Config) MaxRPCCallsPerSecond() uint64

MaxRPCCallsPerSecond returns the rate at which RPC calls can be fired

func (Config) MaximumServiceDuration Uses

func (c Config) MaximumServiceDuration() time.Duration

MaximumServiceDuration is the maximum time that a service agreement can run from after the time it is created. Default 1 year = 365 * 24h = 8760h

func (Config) MinIncomingConfirmations Uses

func (c Config) MinIncomingConfirmations() uint32

MinIncomingConfirmations represents the minimum number of block confirmations that need to be recorded since a job run started before a task can proceed.

func (Config) MinOutgoingConfirmations Uses

func (c Config) MinOutgoingConfirmations() uint64

MinOutgoingConfirmations represents the minimum number of block confirmations that need to be recorded on an outgoing transaction before a task is completed.

func (Config) MinimumContractPayment Uses

func (c Config) MinimumContractPayment() *assets.Link

MinimumContractPayment represents the minimum amount of LINK that must be supplied for a contract to be considered.

func (Config) MinimumRequestExpiration Uses

func (c Config) MinimumRequestExpiration() uint64

MinimumRequestExpiration is the minimum allowed request expiration for a Service Agreement.

func (Config) MinimumServiceDuration Uses

func (c Config) MinimumServiceDuration() time.Duration

MinimumServiceDuration is the shortest duration from now that a service is allowed to run.

func (Config) OracleContractAddress Uses

func (c Config) OracleContractAddress() *common.Address

OracleContractAddress represents the deployed Oracle contract's address.

func (Config) Port Uses

func (c Config) Port() uint16

Port represents the port Chainlink should listen on for client requests.

func (Config) ReaperExpiration Uses

func (c Config) ReaperExpiration() time.Duration

ReaperExpiration represents

func (Config) ReplayFromBlock Uses

func (c Config) ReplayFromBlock() int64

func (Config) RootDir Uses

func (c Config) RootDir() string

RootDir represents the location on the file system where Chainlink should keep its files.

func (Config) SecureCookies Uses

func (c Config) SecureCookies() bool

SecureCookies allows toggling of the secure cookies HTTP flag

func (Config) SessionOptions Uses

func (c Config) SessionOptions() sessions.Options

SessionOptions returns the sesssions.Options struct used to configure the session store.

func (Config) SessionSecret Uses

func (c Config) SessionSecret() ([]byte, error)

SessionSecret returns a sequence of bytes to be used as a private key for session signing or encryption.

func (Config) SessionTimeout Uses

func (c Config) SessionTimeout() time.Duration

SessionTimeout is the maximum duration that a user session can persist without any activity.

func (Config) Set Uses

func (c Config) Set(name string, value interface{})

Set a specific configuration variable

func (Config) SetEthGasPriceDefault Uses

func (c Config) SetEthGasPriceDefault(value *big.Int) error

SetEthGasPriceDefault saves a runtime value for the default gas price for transactions

func (*Config) SetRuntimeStore Uses

func (c *Config) SetRuntimeStore(orm *ORM)

SetRuntimeStore tells the configuration system to use a store for retrieving configuration variables that can be configured at runtime.

func (Config) TLSCertPath Uses

func (c Config) TLSCertPath() string

TLSCertPath represents the file system location of the TLS certificate Chainlink should use for HTTPS.

func (Config) TLSHost Uses

func (c Config) TLSHost() string

TLSHost represents the hostname to use for TLS clients. This should match the TLS certificate.

func (Config) TLSKeyPath Uses

func (c Config) TLSKeyPath() string

TLSKeyPath represents the file system location of the TLS key Chainlink should use for HTTPS.

func (Config) TLSPort Uses

func (c Config) TLSPort() uint16

TLSPort represents the port Chainlink should listen on for encrypted client requests.

func (Config) TLSRedirect Uses

func (c Config) TLSRedirect() bool

TLSRedirect forces TLS redirect for unencrypted connections

func (Config) TxAttemptLimit Uses

func (c Config) TxAttemptLimit() uint16

TxAttemptLimit is the maximum number of transaction attempts (gas bumps) that will occur before giving a transaction up as errored NOTE: That initial transactions are retried forever until they succeed

func (*Config) Validate Uses

func (c *Config) Validate() error

Validate performs basic sanity checks on config and returns error if any misconfiguration would be fatal to the application

type ConfigReader Uses

type ConfigReader interface {
    AllowOrigins() string
    BridgeResponseURL() *url.URL
    ChainID() *big.Int
    ClientNodeURL() string
    DatabaseTimeout() time.Duration
    DatabaseURL() string
    DefaultMaxHTTPAttempts() uint
    DefaultHTTPLimit() int64
    DefaultHTTPTimeout() time.Duration
    Dev() bool
    FeatureExternalInitiators() bool
    FeatureFluxMonitor() bool
    MaximumServiceDuration() time.Duration
    MinimumServiceDuration() time.Duration
    EnableExperimentalAdapters() bool
    EthGasBumpPercent() uint16
    EthGasBumpThreshold() uint64
    EthGasBumpWei() *big.Int
    EthGasLimitDefault() uint64
    EthGasPriceDefault() *big.Int
    EthMaxGasPriceWei() *big.Int
    SetEthGasPriceDefault(value *big.Int) error
    EthereumURL() string
    GasUpdaterBlockDelay() uint16
    GasUpdaterBlockHistorySize() uint16
    GasUpdaterTransactionPercentile() uint16
    JSONConsole() bool
    LinkContractAddress() string
    ExplorerURL() *url.URL
    ExplorerAccessKey() string
    ExplorerSecret() string
    OracleContractAddress() *common.Address
    LogLevel() LogLevel
    LogToDisk() bool
    LogSQLStatements() bool
    MinIncomingConfirmations() uint32
    MinOutgoingConfirmations() uint64
    MinimumContractPayment() *assets.Link
    MinimumRequestExpiration() uint64
    Port() uint16
    ReaperExpiration() time.Duration
    RootDir() string
    SecureCookies() bool
    SessionTimeout() time.Duration
    TLSCertPath() string
    TLSHost() string
    TLSKeyPath() string
    TLSPort() uint16
    TLSRedirect() bool
    TxAttemptLimit() uint16
    KeysDir() string

    KeyFile() string
    CertFile() string
    CreateProductionLogger() *zap.Logger
    SessionSecret() ([]byte, error)
    SessionOptions() sessions.Options
    // contains filtered or unexported methods
}

ConfigReader represents just the read side of the config

type ConfigSchema Uses

type ConfigSchema struct {
    AllowOrigins                    string         `env:"ALLOW_ORIGINS" default:"http://localhost:3000,http://localhost:6688"`
    BridgeResponseURL               url.URL        `env:"BRIDGE_RESPONSE_URL"`
    ChainID                         big.Int        `env:"ETH_CHAIN_ID" default:"1"`
    ClientNodeURL                   string         `env:"CLIENT_NODE_URL" default:"http://localhost:6688"`
    DatabaseTimeout                 time.Duration  `env:"DATABASE_TIMEOUT" default:"500ms"`
    DatabaseURL                     string         `env:"DATABASE_URL"`
    DefaultHTTPLimit                int64          `env:"DEFAULT_HTTP_LIMIT" default:"32768"`
    DefaultHTTPTimeout              time.Duration  `env:"DEFAULT_HTTP_TIMEOUT" default:"15s"`
    Dev                             bool           `env:"CHAINLINK_DEV" default:"false"`
    EnableExperimentalAdapters      bool           `env:"ENABLE_EXPERIMENTAL_ADAPTERS" default:"false"`
    FeatureExternalInitiators       bool           `env:"FEATURE_EXTERNAL_INITIATORS" default:"false"`
    FeatureFluxMonitor              bool           `env:"FEATURE_FLUX_MONITOR" default:"false"`
    MaximumServiceDuration          time.Duration  `env:"MAXIMUM_SERVICE_DURATION" default:"8760h" `
    MinimumServiceDuration          time.Duration  `env:"MINIMUM_SERVICE_DURATION" default:"0s" `
    EthGasBumpThreshold             uint64         `env:"ETH_GAS_BUMP_THRESHOLD" default:"12" `
    EthGasBumpWei                   big.Int        `env:"ETH_GAS_BUMP_WEI" default:"5000000000"`
    EthGasBumpPercent               uint16         `env:"ETH_GAS_BUMP_PERCENT" default:"10"`
    EthGasLimitDefault              uint64         `env:"ETH_GAS_LIMIT_DEFAULT" default:"500000"`
    EthGasPriceDefault              big.Int        `env:"ETH_GAS_PRICE_DEFAULT" default:"20000000000"`
    EthMaxGasPriceWei               uint64         `env:"ETH_MAX_GAS_PRICE_WEI" default:"500000000000"`
    EthereumURL                     string         `env:"ETH_URL" default:"ws://localhost:8546"`
    GasUpdaterBlockDelay            uint16         `env:"GAS_UPDATER_BLOCK_DELAY" default:"3"`
    GasUpdaterBlockHistorySize      uint16         `env:"GAS_UPDATER_BLOCK_HISTORY_SIZE" default:"24"`
    GasUpdaterTransactionPercentile uint16         `env:"GAS_UPDATER_TRANSACTION_PERCENTILE" default:"35"`
    GasUpdaterEnabled               bool           `env:"GAS_UPDATER_ENABLED" default:"false"`
    JSONConsole                     bool           `env:"JSON_CONSOLE" default:"false"`
    LinkContractAddress             string         `env:"LINK_CONTRACT_ADDRESS" default:"0x514910771AF9Ca656af840dff83E8264EcF986CA"`
    ExplorerURL                     *url.URL       `env:"EXPLORER_URL"`
    ExplorerAccessKey               string         `env:"EXPLORER_ACCESS_KEY"`
    ExplorerSecret                  string         `env:"EXPLORER_SECRET"`
    LogLevel                        LogLevel       `env:"LOG_LEVEL" default:"info"`
    LogToDisk                       bool           `env:"LOG_TO_DISK" default:"true"`
    LogSQLStatements                bool           `env:"LOG_SQL" default:"false"`
    LogSQLMigrations                bool           `env:"LOG_SQL_MIGRATIONS" default:"true"`
    DefaultMaxHTTPAttempts          uint           `env:"MAX_HTTP_ATTEMPTS" default:"5"`
    MinIncomingConfirmations        uint32         `env:"MIN_INCOMING_CONFIRMATIONS" default:"3"`
    MinOutgoingConfirmations        uint64         `env:"MIN_OUTGOING_CONFIRMATIONS" default:"12"`
    MinimumContractPayment          assets.Link    `env:"MINIMUM_CONTRACT_PAYMENT" default:"1000000000000000000"`
    MinimumRequestExpiration        uint64         `env:"MINIMUM_REQUEST_EXPIRATION" default:"300"`
    MaxRPCCallsPerSecond            uint64         `env:"MAX_RPC_CALLS_PER_SECOND" default:"500"`
    OracleContractAddress           common.Address `env:"ORACLE_CONTRACT_ADDRESS"`
    Port                            uint16         `env:"CHAINLINK_PORT" default:"6688"`
    ReaperExpiration                time.Duration  `env:"REAPER_EXPIRATION" default:"240h"`
    ReplayFromBlock                 int64          `env:"REPLAY_FROM_BLOCK" default:"-1"`
    RootDir                         string         `env:"ROOT" default:"~/.chainlink"`
    SecureCookies                   bool           `env:"SECURE_COOKIES" default:"true"`
    SessionTimeout                  time.Duration  `env:"SESSION_TIMEOUT" default:"15m"`
    TLSCertPath                     string         `env:"TLS_CERT_PATH" `
    TLSHost                         string         `env:"CHAINLINK_TLS_HOST" `
    TLSKeyPath                      string         `env:"TLS_KEY_PATH" `
    TLSPort                         uint16         `env:"CHAINLINK_TLS_PORT" default:"6689"`
    TLSRedirect                     bool           `env:"CHAINLINK_TLS_REDIRECT" default:"false"`
    TxAttemptLimit                  uint16         `env:"CHAINLINK_TX_ATTEMPT_LIMIT" default:"10"`
}

ConfigSchema records the schema of configuration at the type level

type DialectName Uses

type DialectName string

DialectName is a compiler enforced type used that maps to gorm's dialect names.

const (
    // DialectPostgres represents the postgres dialect.
    DialectPostgres DialectName = "postgres"
)

func DeduceDialect Uses

func DeduceDialect(path string) (DialectName, error)

DeduceDialect returns the appropriate dialect for the passed connection string.

type LockingStrategy Uses

type LockingStrategy interface {
    Lock(timeout time.Duration) error
    Unlock(timeout time.Duration) error
}

LockingStrategy employs the locking and unlocking of an underlying resource for exclusive access, usually a file or database.

func NewLockingStrategy Uses

func NewLockingStrategy(dialect DialectName, dbpath string) (LockingStrategy, error)

NewLockingStrategy returns the locking strategy for a particular dialect to ensure exlusive access to the orm.

func NewPostgresLockingStrategy Uses

func NewPostgresLockingStrategy(path string) (LockingStrategy, error)

NewPostgresLockingStrategy returns a new instance of the PostgresLockingStrategy.

type LogLevel Uses

type LogLevel struct {
    zapcore.Level
}

LogLevel determines the verbosity of the events to be logged.

func (LogLevel) ForGin Uses

func (ll LogLevel) ForGin() string

ForGin keeps Gin's mode at the appropriate level with the LogLevel.

type ORM Uses

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

ORM contains the database object used by Chainlink.

func NewORM Uses

func NewORM(uri string, timeout time.Duration, shutdownSignal gracefulpanic.Signal) (*ORM, error)

NewORM initializes a new database file at the configured uri.

func (*ORM) AddTxAttempt Uses

func (orm *ORM) AddTxAttempt(tx *models.Tx, newTxAttempt *models.Tx) (*models.TxAttempt, error)

AddTxAttempt attaches a new attempt to a Tx, after the attempt has been sent to the chain

func (*ORM) AllSyncEvents Uses

func (orm *ORM) AllSyncEvents(cb func(*models.SyncEvent) error) error

AllSyncEvents returns all sync events

func (*ORM) AnyJobWithType Uses

func (orm *ORM) AnyJobWithType(taskTypeName string) (bool, error)

AnyJobWithType returns true if there is at least one job associated with the type name specified and false otherwise

func (*ORM) ArchiveJob Uses

func (orm *ORM) ArchiveJob(ID *models.ID) error

ArchiveJob soft deletes the job and its associated job runs.

func (*ORM) AuthorizedUserWithSession Uses

func (orm *ORM) AuthorizedUserWithSession(sessionID string, sessionDuration time.Duration) (models.User, error)

AuthorizedUserWithSession will return the one API user if the Session ID exists and hasn't expired, and update session's LastUsed field.

func (*ORM) BridgeTypes Uses

func (orm *ORM) BridgeTypes(offset int, limit int) ([]models.BridgeType, int, error)

BridgeTypes returns bridge types ordered by name filtered limited by the passed params.

func (*ORM) BulkDeleteRuns Uses

func (orm *ORM) BulkDeleteRuns(bulkQuery *models.BulkDeleteRunRequest) error

BulkDeleteRuns removes JobRuns and their related records: TaskRuns and RunResults.

TaskRuns are removed by ON DELETE CASCADE when the JobRuns are deleted, but RunResults are not using foreign keys because multiple foreign keys on a record creates an ambiguity with gorm.

func (*ORM) ClearNonCurrentSessions Uses

func (orm *ORM) ClearNonCurrentSessions(sessionID string) error

ClearNonCurrentSessions removes all sessions but the id passed in.

func (*ORM) ClearSessions Uses

func (orm *ORM) ClearSessions() error

ClearSessions removes all sessions.

func (*ORM) ClobberDiskKeyStoreWithDBKeys Uses

func (orm *ORM) ClobberDiskKeyStoreWithDBKeys(keysDir string) error

ClobberDiskKeyStoreWithDBKeys writes all keys stored in the orm to the keys folder on disk, deleting anything there prior.

func (*ORM) Close Uses

func (orm *ORM) Close() error

Close closes the underlying database connection.

func (*ORM) CountOf Uses

func (orm *ORM) CountOf(t interface{}) (int, error)

func (*ORM) CreateBridgeType Uses

func (orm *ORM) CreateBridgeType(bt *models.BridgeType) error

CreateBridgeType saves the bridge type.

func (*ORM) CreateExternalInitiator Uses

func (orm *ORM) CreateExternalInitiator(externalInitiator *models.ExternalInitiator) error

CreateExternalInitiator inserts a new external initiator

func (*ORM) CreateHead Uses

func (orm *ORM) CreateHead(n *models.Head) error

CreateHead creates a head record that tracks which block heads we've observed in the HeadTracker

func (*ORM) CreateInitiator Uses

func (orm *ORM) CreateInitiator(initr *models.Initiator) error

CreateInitiator saves the initiator.

func (*ORM) CreateJob Uses

func (orm *ORM) CreateJob(job *models.JobSpec) error

CreateJob saves a job to the database and adds IDs to associated tables.

func (*ORM) CreateJobRun Uses

func (orm *ORM) CreateJobRun(run *models.JobRun) error

CreateJobRun inserts a new JobRun

func (*ORM) CreateServiceAgreement Uses

func (orm *ORM) CreateServiceAgreement(sa *models.ServiceAgreement) error

CreateServiceAgreement saves a Service Agreement, its JobSpec and its associations to the database.

func (*ORM) CreateSession Uses

func (orm *ORM) CreateSession(sr models.SessionRequest) (string, error)

CreateSession will check the password in the SessionRequest against the hashed API User password in the db.

func (*ORM) CreateTx Uses

func (orm *ORM) CreateTx(tx *models.Tx) (*models.Tx, error)

CreateTx returns a transaction by its surrogate key, if it exists, or creates it

func (*ORM) DeleteBridgeType Uses

func (orm *ORM) DeleteBridgeType(bt *models.BridgeType) error

DeleteBridgeType removes the bridge type

func (*ORM) DeleteEncryptedSecretVRFKey Uses

func (orm *ORM) DeleteEncryptedSecretVRFKey(k *models.EncryptedSecretVRFKey) error

DeleteEncryptedSecretKey deletes k from the encrypted keys table, or errors

func (*ORM) DeleteExternalInitiator Uses

func (orm *ORM) DeleteExternalInitiator(name string) error

DeleteExternalInitiator removes an external initiator

func (*ORM) DeleteStaleSessions Uses

func (orm *ORM) DeleteStaleSessions(before time.Time) error

DeleteStaleSessions deletes all sessions before the passed time.

func (*ORM) DeleteTransaction Uses

func (orm *ORM) DeleteTransaction(ethtx *models.Tx) error

DeleteTransaction deletes a transaction an all of its attempts.

func (*ORM) DeleteUser Uses

func (orm *ORM) DeleteUser() (models.User, error)

DeleteUser will delete the API User in the db.

func (*ORM) DeleteUserSession Uses

func (orm *ORM) DeleteUserSession(sessionID string) error

DeleteUserSession will erase the session ID for the sole API User.

func (*ORM) FindAllTxsInNonceRange Uses

func (orm *ORM) FindAllTxsInNonceRange(beginningNonce uint, endingNonce uint) ([]models.Tx, error)

FindAllTxsInNonceRange returns an array of transactions matching the inclusive range between beginningNonce and endingNonce

func (*ORM) FindBridge Uses

func (orm *ORM) FindBridge(name models.TaskType) (models.BridgeType, error)

FindBridge looks up a Bridge by its Name.

func (*ORM) FindBridgesByNames Uses

func (orm *ORM) FindBridgesByNames(names []string) ([]models.BridgeType, error)

FindBridgesByNames finds multiple bridges by their names.

func (*ORM) FindEncryptedSecretVRFKeys Uses

func (orm *ORM) FindEncryptedSecretVRFKeys(where ...models.EncryptedSecretVRFKey) (
    retrieved []*models.EncryptedSecretVRFKey, err error)

FindEncryptedSecretKeys retrieves matches to where from the encrypted keys table, or errors

func (*ORM) FindExternalInitiator Uses

func (orm *ORM) FindExternalInitiator(
    eia *auth.Token,
) (*models.ExternalInitiator, error)

FindExternalInitiator finds an external initiator given an authentication request

func (*ORM) FindExternalInitiatorByName Uses

func (orm *ORM) FindExternalInitiatorByName(iname string) (models.ExternalInitiator, error)

FindExternalInitiatorByName finds an external initiator given an authentication request

func (*ORM) FindInitiator Uses

func (orm *ORM) FindInitiator(ID uint) (models.Initiator, error)

FindInitiator returns the single initiator defined by the passed ID.

func (*ORM) FindJob Uses

func (orm *ORM) FindJob(id *models.ID) (models.JobSpec, error)

FindJob looks up a Job by its ID.

func (*ORM) FindJobRun Uses

func (orm *ORM) FindJobRun(id *models.ID) (models.JobRun, error)

FindJobRun looks up a JobRun by its ID.

func (*ORM) FindLogCursor Uses

func (orm *ORM) FindLogCursor(name string) (models.LogCursor, error)

FindLogCursor will find the given log cursor.

func (*ORM) FindServiceAgreement Uses

func (orm *ORM) FindServiceAgreement(id string) (models.ServiceAgreement, error)

FindServiceAgreement looks up a ServiceAgreement by its ID.

func (*ORM) FindTx Uses

func (orm *ORM) FindTx(ID uint64) (*models.Tx, error)

FindTx returns the specific transaction for the passed ID.

func (*ORM) FindTxAttempt Uses

func (orm *ORM) FindTxAttempt(hash common.Hash) (*models.TxAttempt, error)

FindTxAttempt returns an individual TxAttempt

func (*ORM) FindTxByAttempt Uses

func (orm *ORM) FindTxByAttempt(hash common.Hash) (*models.Tx, *models.TxAttempt, error)

FindTxByAttempt returns the specific transaction attempt with the hash.

func (*ORM) FindTxsBySenderAndRecipient Uses

func (orm *ORM) FindTxsBySenderAndRecipient(sender, recipient common.Address, offset, limit uint) ([]models.Tx, error)

FindTxsBySenderAndRecipient returns an array of transactions sent by `sender` to `recipient`

func (*ORM) FindUser Uses

func (orm *ORM) FindUser() (models.User, error)

FindUser will return the one API user, or an error.

func (*ORM) FirstHead Uses

func (orm *ORM) FirstHead() (*models.Head, error)

FirstHead returns the oldest persisted head entry.

func (*ORM) FirstOrCreateEncryptedSecretVRFKey Uses

func (orm *ORM) FirstOrCreateEncryptedSecretVRFKey(k *models.EncryptedSecretVRFKey) error

FirstOrCreateEncryptedSecretKey returns the first key found or creates a new one in the orm.

func (*ORM) FirstOrCreateKey Uses

func (orm *ORM) FirstOrCreateKey(k *models.Key) error

FirstOrCreateKey returns the first key found or creates a new one in the orm.

func (*ORM) GetConfigValue Uses

func (orm *ORM) GetConfigValue(field string, value encoding.TextUnmarshaler) error

GetConfigValue returns the value for a named configuration entry

func (*ORM) GetLastNonce Uses

func (orm *ORM) GetLastNonce(address common.Address) (uint64, error)

GetLastNonce retrieves the last known nonce in the database for an account

func (*ORM) JobRunsCountFor Uses

func (orm *ORM) JobRunsCountFor(jobSpecID *models.ID) (int, error)

JobRunsCountFor returns the current number of runs for the job

func (*ORM) JobRunsFor Uses

func (orm *ORM) JobRunsFor(jobSpecID *models.ID, limit ...int) ([]models.JobRun, error)

JobRunsFor fetches all JobRuns with a given Job ID, sorted by their created at time.

func (*ORM) JobRunsSorted Uses

func (orm *ORM) JobRunsSorted(sort SortType, offset int, limit int) ([]models.JobRun, int, error)

JobRunsSorted returns job runs ordered and filtered by the passed params.

func (*ORM) JobRunsSortedFor Uses

func (orm *ORM) JobRunsSortedFor(id *models.ID, order SortType, offset int, limit int) ([]models.JobRun, int, error)

JobRunsSortedFor returns job runs for a specific job spec ordered and filtered by the passed params.

func (*ORM) Jobs Uses

func (orm *ORM) Jobs(cb func(*models.JobSpec) bool, initrTypes ...string) error

Jobs fetches all jobs.

func (*ORM) JobsSorted Uses

func (orm *ORM) JobsSorted(sort SortType, offset int, limit int) ([]models.JobSpec, int, error)

JobsSorted returns many JobSpecs sorted by CreatedAt from the store adhering to the passed parameters.

func (*ORM) Keys Uses

func (orm *ORM) Keys() ([]*models.Key, error)

Keys returns all keys stored in the orm.

func (*ORM) LastHead Uses

func (orm *ORM) LastHead() (*models.Head, error)

LastHead returns the most recently persisted head entry.

func (*ORM) LinkEarnedFor Uses

func (orm *ORM) LinkEarnedFor(spec *models.JobSpec) (*assets.Link, error)

LinkEarnedFor shows the total link earnings for a job

func (*ORM) MarkRan Uses

func (orm *ORM) MarkRan(i *models.Initiator, ran bool) error

MarkRan will set Ran to true for a given initiator

func (*ORM) MarkTxSafe Uses

func (orm *ORM) MarkTxSafe(tx *models.Tx, txAttempt *models.TxAttempt) error

MarkTxSafe updates the database for the given transaction and attempt to show that the transaction has not just been confirmed, but has met the minimum number of outgoing confirmations to be deemed safely written on the blockchain.

func (*ORM) MustEnsureAdvisoryLock Uses

func (orm *ORM) MustEnsureAdvisoryLock()

func (*ORM) PendingBridgeType Uses

func (orm *ORM) PendingBridgeType(jr models.JobRun) (models.BridgeType, error)

PendingBridgeType returns the bridge type of the current pending task, or error if not pending bridge.

func (*ORM) RawDB Uses

func (orm *ORM) RawDB(fn func(*gorm.DB) error) error

func (*ORM) SaveJobRun Uses

func (orm *ORM) SaveJobRun(run *models.JobRun) error

SaveJobRun updates UpdatedAt for a JobRun and saves it

func (*ORM) SaveLogCursor Uses

func (orm *ORM) SaveLogCursor(logCursor *models.LogCursor) error

SaveLogCursor saves the log cursor.

func (*ORM) SaveSession Uses

func (orm *ORM) SaveSession(session *models.Session) error

SaveSession saves the session.

func (*ORM) SaveTx Uses

func (orm *ORM) SaveTx(tx *models.Tx) error

SaveTx saves the Ethereum Transaction.

func (*ORM) SaveUser Uses

func (orm *ORM) SaveUser(user *models.User) error

SaveUser saves the user.

func (*ORM) Sessions Uses

func (orm *ORM) Sessions(offset, limit int) ([]models.Session, error)

Sessions returns all sessions limited by the parameters.

func (*ORM) SetConfigValue Uses

func (orm *ORM) SetConfigValue(field string, value encoding.TextMarshaler) error

SetConfigValue returns the value for a named configuration entry

func (*ORM) SetLogging Uses

func (orm *ORM) SetLogging(enabled bool)

SetLogging turns on SQL statement logging

func (*ORM) Transactions Uses

func (orm *ORM) Transactions(offset, limit int) ([]models.Tx, int, error)

Transactions returns all transactions limited by passed parameters.

func (*ORM) TxAttempts Uses

func (orm *ORM) TxAttempts(offset, limit int) ([]models.TxAttempt, int, error)

TxAttempts returns the last tx attempts sorted by sent at descending.

func (*ORM) TxFrom Uses

func (orm *ORM) TxFrom(from common.Address) ([]models.Tx, error)

TxFrom returns all transactions from a particular address.

func (*ORM) UnconfirmedTxAttempts Uses

func (orm *ORM) UnconfirmedTxAttempts() ([]models.TxAttempt, error)

UnconfirmedTxAttempts returns all TxAttempts for which the associated Tx is still unconfirmed.

func (*ORM) Unscoped Uses

func (orm *ORM) Unscoped() *ORM

Unscoped returns a new instance of this ORM that includes soft deleted items.

func (*ORM) UnscopedJobRunsWithStatus Uses

func (orm *ORM) UnscopedJobRunsWithStatus(cb func(*models.JobRun), statuses ...models.RunStatus) error

UnscopedJobRunsWithStatus passes all JobRuns to a callback, one by one, including those that were soft deleted.

func (*ORM) UpdateBridgeType Uses

func (orm *ORM) UpdateBridgeType(bt *models.BridgeType, btr *models.BridgeTypeRequest) error

UpdateBridgeType updates the bridge type.

func (*ORM) Where Uses

func (orm *ORM) Where(field string, value interface{}, instance interface{}) error

Where fetches multiple objects with "Find".

type PostgresLockingStrategy Uses

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

PostgresLockingStrategy uses a postgres advisory lock to ensure exclusive access.

func (*PostgresLockingStrategy) Lock Uses

func (s *PostgresLockingStrategy) Lock(timeout time.Duration) error

Lock uses a blocking postgres advisory lock that times out at the passed timeout.

func (*PostgresLockingStrategy) Unlock Uses

func (s *PostgresLockingStrategy) Unlock(timeout time.Duration) error

Unlock unlocks the locked postgres advisory lock.

type SecretGenerator Uses

type SecretGenerator interface {
    Generate(Config) ([]byte, error)
}

SecretGenerator is the interface for objects that generate a secret used to sign or encrypt.

type SortType Uses

type SortType int

SortType defines the different sort orders available.

const (
    // Ascending is the sort order going up, i.e. 1,2,3.
    Ascending SortType = iota
    // Descending is the sort order going down, i.e. 3,2,1.
    Descending
)

func (SortType) String Uses

func (s SortType) String() string

Package orm imports 38 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: