orm

package
v0.0.0-...-5cb58b4 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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) 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() ([]models.JobSpec, 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) SaveCreationHeight

func (orm *ORM) SaveCreationHeight(jr models.JobRun, bn *models.IndexableBlockNumber) (models.JobRun, error)

SaveCreationHeight stores the JobRun in the database with the given block number.

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