orm

package
v0.6.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2019 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorNotFound is returned when finding a single value fails.
	ErrorNotFound = gorm.ErrRecordNotFound
)

Functions

func Batch

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

Batch is an iterator _like_ for batches of records

func EnvVarName added in v0.6.6

func EnvVarName(field string) string

EnvVarName gets the environment variable name for a config schema field

func NormalizedDatabaseURL added in v0.6.6

func NormalizedDatabaseURL(c ConfigReader) string

NormalizedDatabaseURL returns the DatabaseURL with the empty default coerced to a sqlite3 URL.

Types

type Config added in v0.6.6

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 added in v0.6.6

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 added in v0.6.6

func (c Config) AllowOrigins() string

AllowOrigins returns the CORS hosts used by the frontend.

func (Config) BridgeResponseURL added in v0.6.6

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

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

func (Config) CertFile added in v0.6.6

func (c Config) CertFile() string

CertFile returns the path where the server certificate is kept

func (Config) ChainID added in v0.6.6

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

ChainID represents the chain ID to use for transactions.

func (Config) ClientNodeURL added in v0.6.6

func (c Config) ClientNodeURL() string

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

func (Config) CreateProductionLogger added in v0.6.6

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 added in v0.6.6

func (c Config) DatabaseTimeout() time.Duration

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

func (Config) DatabaseURL added in v0.6.6

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://, file://), or an empty string, so the application defaults to .chainlink/db.sqlite.

func (Config) DefaultHTTPLimit added in v0.6.6

func (c Config) DefaultHTTPLimit() int64

DefaultHTTPLimit defines the limit for HTTP requests.

func (Config) Dev added in v0.6.6

func (c Config) Dev() bool

Dev configures "development" mode for chainlink.

func (Config) EthGasBumpThreshold added in v0.6.6

func (c Config) EthGasBumpThreshold() uint64

EthGasBumpThreshold represents the maximum amount a transaction's ETH amount should be increased in order to facilitate a transaction.

func (Config) EthGasBumpWei added in v0.6.6

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

EthGasBumpWei represents the intervals in which ETH should be increased when doing gas bumping.

func (Config) EthGasPriceDefault added in v0.6.6

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

EthGasPriceDefault represents the default gas price for transactions.

func (Config) EthereumURL added in v0.6.6

func (c Config) EthereumURL() string

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

func (Config) ExplorerAccessKey added in v0.6.6

func (c Config) ExplorerAccessKey() string

ExplorerAccessKey returns the access key for authenticating with explorer

func (Config) ExplorerSecret added in v0.6.6

func (c Config) ExplorerSecret() string

ExplorerSecret returns the secret for authenticating with explorer

func (Config) ExplorerURL added in v0.6.6

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

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

func (Config) JSONConsole added in v0.6.6

func (c Config) JSONConsole() bool

JSONConsole enables the JSON console.

func (Config) KeyFile added in v0.6.6

func (c Config) KeyFile() string

KeyFile returns the path where the server key is kept

func (Config) KeysDir added in v0.6.6

func (c Config) KeysDir() string

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

func (Config) LinkContractAddress added in v0.6.6

func (c Config) LinkContractAddress() string

LinkContractAddress represents the address

func (Config) LogLevel added in v0.6.6

func (c Config) LogLevel() LogLevel

LogLevel represents the maximum level of log messages to output.

func (Config) LogSQLMigrations added in v0.6.6

func (c Config) LogSQLMigrations() bool

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

func (Config) LogSQLStatements added in v0.6.6

func (c Config) LogSQLStatements() bool

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

func (Config) LogToDisk added in v0.6.6

func (c Config) LogToDisk() bool

LogToDisk configures disk preservation of logs.

func (Config) MaxRPCCallsPerSecond added in v0.6.6

func (c Config) MaxRPCCallsPerSecond() uint64

MaxRPCCallsPerSecond returns the rate at which RPC calls can be fired

func (Config) MaximumServiceDuration added in v0.6.6

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 added in v0.6.6

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 added in v0.6.6

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 added in v0.6.6

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

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

func (Config) MinimumRequestExpiration added in v0.6.6

func (c Config) MinimumRequestExpiration() uint64

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

func (Config) MinimumServiceDuration added in v0.6.6

func (c Config) MinimumServiceDuration() time.Duration

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

func (Config) OracleContractAddress added in v0.6.6

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

OracleContractAddress represents the deployed Oracle contract's address.

func (Config) Port added in v0.6.6

func (c Config) Port() uint16

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

func (Config) ReaperExpiration added in v0.6.6

func (c Config) ReaperExpiration() time.Duration

ReaperExpiration represents

func (Config) RootDir added in v0.6.6

func (c Config) RootDir() string

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

func (Config) SecureCookies added in v0.6.6

func (c Config) SecureCookies() bool

SecureCookies allows toggling of the secure cookies HTTP flag

func (Config) SessionOptions added in v0.6.6

func (c Config) SessionOptions() sessions.Options

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

func (Config) SessionSecret added in v0.6.6

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 added in v0.6.6

func (c Config) SessionTimeout() time.Duration

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

func (Config) Set added in v0.6.6

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

Set a specific configuration variable

func (Config) SetEthGasPriceDefault added in v0.6.6

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

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

func (*Config) SetRuntimeStore added in v0.6.6

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 added in v0.6.6

func (c Config) TLSCertPath() string

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

func (Config) TLSHost added in v0.6.6

func (c Config) TLSHost() string

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

func (Config) TLSKeyPath added in v0.6.6

func (c Config) TLSKeyPath() string

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

func (Config) TLSPort added in v0.6.6

func (c Config) TLSPort() uint16

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

func (Config) TLSRedirect added in v0.6.6

func (c Config) TLSRedirect() bool

TLSRedirect forces TLS redirect for unencrypted connections

func (Config) TxAttemptLimit added in v0.6.6

func (c Config) TxAttemptLimit() uint16

TxAttemptLimit represents the maximum number of transaction attempts that the TxManager should allow to for a transaction

type ConfigReader added in v0.6.6

type ConfigReader interface {
	AllowOrigins() string
	BridgeResponseURL() *url.URL
	ChainID() *big.Int
	ClientNodeURL() string
	DatabaseTimeout() time.Duration
	DatabaseURL() string
	DefaultHTTPLimit() int64
	Dev() bool
	MaximumServiceDuration() time.Duration
	MinimumServiceDuration() time.Duration
	EthGasBumpThreshold() uint64
	EthGasBumpWei() *big.Int
	EthGasPriceDefault() *big.Int
	SetEthGasPriceDefault(value *big.Int) error
	EthereumURL() string
	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 added in v0.6.6

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:"0"`
	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"`
	Dev                      bool           `env:"CHAINLINK_DEV" 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"`
	EthGasPriceDefault       big.Int        `env:"ETH_GAS_PRICE_DEFAULT" default:"20000000000"`
	EthereumURL              string         `env:"ETH_URL" default:"ws://localhost:8546"`
	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"`
	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"`
	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

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"
	// DialectSqlite represents the sqlite dialect.
	DialectSqlite = "sqlite3"
)

func DeduceDialect

func DeduceDialect(path string) (DialectName, error)

DeduceDialect returns the appropriate dialect for the passed connection string.

type FileLockingStrategy

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

FileLockingStrategy uses a file lock on disk to ensure exclusive access.

func (*FileLockingStrategy) Lock

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

Lock returns immediately and assumes is always unlocked.

func (*FileLockingStrategy) Unlock

func (s *FileLockingStrategy) Unlock() error

Unlock is a noop.

type LockingStrategy

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

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

func NewFileLockingStrategy

func NewFileLockingStrategy(dbpath string) (LockingStrategy, error)

NewFileLockingStrategy creates a new instance of FileLockingStrategy at the passed path.

func NewLockingStrategy

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

func NewPostgresLockingStrategy(path string) (LockingStrategy, error)

NewPostgresLockingStrategy returns a new instance of the PostgresLockingStrategy.

type LogLevel added in v0.6.6

type LogLevel struct {
	zapcore.Level
}

LogLevel determines the verbosity of the events to be logged.

func (LogLevel) ForGin added in v0.6.6

func (ll LogLevel) ForGin() string

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

type ORM

type ORM struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

ORM contains the database object used by Chainlink.

func NewORM

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

NewORM initializes a new database file at the configured uri.

func (*ORM) AddTxAttempt

func (orm *ORM) AddTxAttempt(
	tx *models.Tx,
	etx *types.Transaction,
	blkNum uint64,
) (*models.TxAttempt, error)

AddTxAttempt creates a new transaction attempt and stores it in the database.

func (*ORM) AllSyncEvents

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

AllSyncEvents returns all sync events

func (*ORM) AnyJobWithType

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

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

ArchiveJob soft deletes the job and its associated job runs.

func (*ORM) Archived

func (orm *ORM) Archived(id *models.ID) bool

Archived returns whether or not a job has been archived.

func (*ORM) AuthorizedUserWithSession

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

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

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

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

ClearNonCurrentSessions removes all sessions but the id passed in.

func (*ORM) ClearSessions

func (orm *ORM) ClearSessions() error

ClearSessions removes all sessions.

func (*ORM) ClobberDiskKeyStoreWithDBKeys

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

func (orm *ORM) Close() error

Close closes the underlying database connection.

func (*ORM) CreateBridgeType

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

CreateBridgeType saves the bridge type.

func (*ORM) CreateExternalInitiator

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

CreateExternalInitiator inserts a new external initiator

func (*ORM) CreateHead added in v0.6.1

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

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

CreateInitiator saves the initiator.

func (*ORM) CreateJob

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

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

func (*ORM) CreateJobRun

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

CreateJobRun inserts a new JobRun

func (*ORM) CreateServiceAgreement

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

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

func (*ORM) CreateSession

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

func (orm *ORM) CreateTx(
	surrogateID null.String,
	ethTx *types.Transaction,
	from *common.Address,
	sentAt uint64,
) (*models.Tx, error)

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

func (*ORM) DeleteBridgeType

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

DeleteBridgeType removes the bridge type

func (*ORM) DeleteExternalInitiator

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

DeleteExternalInitiator removes an external initiator

func (*ORM) DeleteJobRun

func (orm *ORM) DeleteJobRun(ID string) error

DeleteJobRun deletes the job run and corresponding task runs.

func (*ORM) DeleteStaleSessions

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

DeleteStaleSessions deletes all sessions before the passed time.

func (*ORM) DeleteTransaction

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

DeleteTransaction deletes a transaction an all of its attempts.

func (*ORM) DeleteUser

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

DeleteUser will delete the API User in the db.

func (*ORM) DeleteUserSession

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

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

func (*ORM) DialectName

func (orm *ORM) DialectName() DialectName

func (*ORM) FindBridge

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

FindBridge looks up a Bridge by its Name.

func (*ORM) FindExternalInitiator

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

FindExternalInitiator finds an external initiator given an authentication request

func (*ORM) FindExternalInitiatorByName added in v0.6.6

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

FindExternalInitiatorByName finds an external initiator given an authentication request

func (*ORM) FindInitiator

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

FindInitiator returns the single initiator defined by the passed ID.

func (*ORM) FindJob

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

FindJob looks up a Job by its ID.

func (*ORM) FindJobRun

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

FindJobRun looks up a JobRun by its ID.

func (*ORM) FindServiceAgreement

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

FindServiceAgreement looks up a ServiceAgreement by its ID.

func (*ORM) FindTx

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

FindTx returns the specific transaction for the passed ID.

func (*ORM) FindTxAttempt

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

FindTxAttempt returns an individual TxAttempt

func (*ORM) FindTxByAttempt

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

FindTxByAttempt returns the specific transaction attempt with the hash.

func (*ORM) FindUser

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

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

func (*ORM) FirstHead added in v0.6.6

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

FirstHead returns the oldest persisted head entry.

func (*ORM) FirstOrCreateKey

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 added in v0.6.6

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

GetConfigValue returns the value for a named configuration entry

func (*ORM) GetLastNonce

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

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

func (*ORM) JobRunsCountFor

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

JobRunsCountFor returns the current number of runs for the job

func (*ORM) JobRunsFor

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

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

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

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

Jobs fetches all jobs.

func (*ORM) JobsSorted

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

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

Keys returns all keys stored in the orm.

func (*ORM) LastHead

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

LastHead returns the most recently persisted head entry.

func (*ORM) LinkEarnedFor added in v0.6.6

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

LinkEarnedFor shows the total link earnings for a job

func (*ORM) MarkRan

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

MarkRan will set Ran to true for a given initiator

func (*ORM) MarkTxSafe

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) PendingBridgeType

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) SaveJobRun

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

SaveJobRun updates UpdatedAt for a JobRun and saves it

func (*ORM) SaveSession

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

SaveSession saves the session.

func (*ORM) SaveTx added in v0.6.8

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

SaveTx saves the Ethereum Transaction.

func (*ORM) SaveUser

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

SaveUser saves the user.

func (*ORM) Sessions

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

Sessions returns all sessions limited by the parameters.

func (*ORM) SetConfigValue added in v0.6.6

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

SetConfigValue returns the value for a named configuration entry

func (*ORM) SetLogging added in v0.6.1

func (orm *ORM) SetLogging(enabled bool)

SetLogging turns on SQL statement logging

func (*ORM) Transactions

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

Transactions returns all transactions limited by passed parameters.

func (*ORM) TxAttempts

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

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

TxFrom returns all transactions from a particular address.

func (*ORM) Unscoped

func (orm *ORM) Unscoped() *ORM

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

func (*ORM) UnscopedJobRunsWithStatus

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

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

UpdateBridgeType updates the bridge type.

func (*ORM) UpdateTx

func (orm *ORM) UpdateTx(
	tx *models.Tx,
	ethTx *types.Transaction,
	from *common.Address,
	sentAt uint64,
) error

UpdateTx assigns new EthTx details to a transaction, typically used after a failed Eth transaction attempt

func (*ORM) Where

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

Where fetches multiple objects with "Find".

type PostgresLockingStrategy

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

PostgresLockingStrategy uses a postgres advisory lock to ensure exclusive access.

func (*PostgresLockingStrategy) Lock

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

func (s *PostgresLockingStrategy) Unlock() error

Unlock unlocks the locked postgres advisory lock.

type SecretGenerator added in v0.6.6

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

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

type SortType

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

func (s SortType) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL