orm

package
v0.0.0-...-73326a6 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorInvalidCallbackSignature is returned in AllInBatches if the incorrect function signature is passed.
	ErrorInvalidCallbackSignature = errors.New("AllInBatches callback has incorrect function signature, must return bool")
	// ErrorInvalidCallbackModel is returned in AllInBatches if the model and bucket do not match types.
	ErrorInvalidCallbackModel = errors.New("AllInBatches callback has incorrect model, must match bucket")
)

Functions

This section is empty.

Types

type ORM

type ORM struct {
	*storm.DB
}

ORM contains the database object used by Chainlink.

func NewORM

func NewORM(path string, duration time.Duration) (*ORM, error)

NewORM initializes a new database file at the configured path.

func (*ORM) AddAttempt

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

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

func (*ORM) AllInBatches

func (orm *ORM) AllInBatches(bucket interface{}, callback interface{}, optionalBatchSize ...int) error

AllInBatches iterates over every single entry in the passed bucket without holding the entire contents in memory, pulling down batches and streaming over each entry. Be sure not to use the passed bucket parameter as it is used as a buffer.

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

func (orm *ORM) AttemptsFor(id uint64) ([]models.TxAttempt, error)

AttemptsFor returns the Transaction Attempts (TxAttempt) for a given Transaction ID (TxID).

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

func (orm *ORM) ConfirmTx(tx *models.Tx, txat *models.TxAttempt) error

ConfirmTx updates the database for the given transaction to show that the transaction has been confirmed on the blockchain.

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(
	from common.Address,
	nonce uint64,
	to common.Address,
	data []byte,
	value *big.Int,
	gasLimit uint64,
) (*models.Tx, error)

CreateTx saves the properties of an Ethereum transaction to the database.

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

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

FindBridge looks up a Bridge by its Name.

func (*ORM) FindJob

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

FindJob looks up a Job by its ID.

func (*ORM) FindJobRun

func (orm *ORM) FindJobRun(id string) (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) FindUser

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

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

func (*ORM) GetBolt

func (orm *ORM) GetBolt() *bolt.DB

GetBolt returns BoltDB from the ORM

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

func (orm *ORM) InitBucket(model interface{}) error

InitBucket initializes buckets and indexes before saving an object.

func (*ORM) InitializeModel

func (orm *ORM) InitializeModel(klass interface{}) error

InitializeModel uses reflection on the passed klass to generate a bucket of the same type name.

func (*ORM) JobRunsCountFor

func (orm *ORM) JobRunsCountFor(jobID string) (int, error)

JobRunsCountFor returns the current number of runs for the job

func (*ORM) JobRunsFor

func (orm *ORM) JobRunsFor(jobID string) ([]models.JobRun, error)

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

func (*ORM) JobRunsWithStatus

func (orm *ORM) JobRunsWithStatus(statuses ...models.RunStatus) ([]models.JobRun, error)

JobRunsWithStatus returns the JobRuns which have the passed statuses.

func (*ORM) Jobs

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

Jobs fetches all jobs.

func (*ORM) MarkRan

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

MarkRan will set Ran to true for a given initiator

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

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

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

func (*ORM) SaveJobRun

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

SaveJobRun updates UpdatedAt for a JobRun and saves it

func (*ORM) SaveServiceAgreement

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

SaveServiceAgreement saves a service agreement and it's associations to the database.

func (*ORM) Where

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

Where fetches multiple objects with "Find" in Storm.

Jump to

Keyboard shortcuts

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