store

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: MIT Imports: 44 Imported by: 12

Documentation

Overview

Package store is used to keep application events in sync between the database on the node and the blockchain.

Config

Config contains the local configuration options that the application will adhere to.

EthClient

This makes use of Go-Ethereum's functions to interact with the blockchain. The underlying functions can be viewed here:

go-ethereum/rpc/client.go

KeyStore

KeyStore also utilizes Go-Ethereum's functions to store encrypted keys on the local file system. The underlying functions can be viewed here:

go-ethereum/accounts/keystore/keystore.go

Store

The Store is the persistence layer for the application. It saves the the application state and most interaction with the node needs to occur through the store.

Tx Manager

The transaction manager is used to syncronize interactions on the Ethereum blockchain with the application and database.

Index

Constants

View Source
const DefaultGasLimit uint64 = 500000

DefaultGasLimit sets the default gas limit for outgoing transactions. if updating DefaultGasLimit, be sure it matches with the DefaultGasLimit specified in evm/test/Oracle_test.js

Variables

View Source
var ErrPendingConnection = errors.New("Cannot talk to chain, pending connection")

ErrPendingConnection is the error returned if TxManager is not connected.

View Source
var Sha = "unset"

Sha string "unset"

View Source
var Version = "unset"

Version the version of application

Functions

func ExtractERC20BalanceTargetAddress

func ExtractERC20BalanceTargetAddress(args interface{}) (common.Address, bool)

ExtractERC20BalanceTargetAddress returns the address whose balance is being queried by the message in the given call to an ERC20 contract, which is interpreted as a callArgs.

Types

type AttemptState

type AttemptState int

AttemptState enumerates the possible states of a transaction attempt as it gets accepted and confirmed by the blockchain

const (
	// Unknown is returned when the state of a transaction could not be
	// determined because of an error
	Unknown AttemptState = iota
	// Unconfirmed means that a transaction has had no confirmations at all
	Unconfirmed
	// Confirmed means that a transaftion has had at least one transaction, but
	// not enough to satisfy the minimum number of confirmations configuration
	// option
	Confirmed
	// Safe has the required number of confirmations or more
	Safe
)

func (AttemptState) String

func (a AttemptState) String() string

String conforms to the Stringer interface for AttemptState

type CallerSubscriber

type CallerSubscriber interface {
	Call(result interface{}, method string, args ...interface{}) error
	EthSubscribe(context.Context, interface{}, ...interface{}) (models.EthSubscription, error)
}

CallerSubscriber implements the Call and EthSubscribe functions. Call performs a JSON-RPC call with the given arguments and EthSubscribe registers a subscription.

type Config

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

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

func (c Config) AllowOrigins() string

AllowOrigins returns the CORS hosts used by the frontend.

func (Config) BridgeResponseURL

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

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

func (Config) CertFile

func (c Config) CertFile() string

CertFile returns the path where the server certificate is kept

func (Config) ChainID

func (c Config) ChainID() uint64

ChainID represents the chain ID to use for transactions.

func (Config) ClientNodeURL

func (c Config) ClientNodeURL() string

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

func (Config) CreateProductionLogger

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

func (c Config) DatabaseTimeout() time.Duration

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

func (Config) DatabaseURL

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

func (c Config) DefaultHTTPLimit() int64

DefaultHTTPLimit defines the limit for HTTP requests.

func (Config) Dev

func (c Config) Dev() bool

Dev configures "development" mode for chainlink.

func (Config) EthGasBumpThreshold

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

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

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

func (Config) EthGasPriceDefault

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

EthGasPriceDefault represents the default gas price for transactions.

func (Config) EthereumURL

func (c Config) EthereumURL() string

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

func (Config) ExplorerAccessKey

func (c Config) ExplorerAccessKey() string

ExplorerAccessKey returns the access key for authenticating with explorer

func (Config) ExplorerSecret

func (c Config) ExplorerSecret() string

ExplorerSecret returns the secret for authenticating with explorer

func (Config) ExplorerURL

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

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

func (Config) JSONConsole

func (c Config) JSONConsole() bool

JSONConsole enables the JSON console.

func (Config) KeyFile

func (c Config) KeyFile() string

KeyFile returns the path where the server key is kept

func (Config) KeysDir

func (c Config) KeysDir() string

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

func (Config) LinkContractAddress

func (c Config) LinkContractAddress() string

LinkContractAddress represents the address

func (Config) LogLevel

func (c Config) LogLevel() LogLevel

LogLevel represents the maximum level of log messages to output.

func (Config) LogSQLStatements

func (c Config) LogSQLStatements() bool

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

func (Config) LogToDisk

func (c Config) LogToDisk() bool

LogToDisk configures disk preservation of logs.

func (Config) MaximumServiceDuration

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

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

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

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

func (c Config) MinimumRequestExpiration() uint64

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

func (Config) MinimumServiceDuration

func (c Config) MinimumServiceDuration() time.Duration

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

func (Config) NormalizedDatabaseURL

func (c Config) NormalizedDatabaseURL() string

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

func (Config) OracleContractAddress

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

OracleContractAddress represents the deployed Oracle contract's address.

func (Config) Port

func (c Config) Port() uint16

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

func (Config) ReaperExpiration

func (c Config) ReaperExpiration() time.Duration

ReaperExpiration represents

func (Config) RootDir

func (c Config) RootDir() string

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

func (Config) SecureCookies

func (c Config) SecureCookies() bool

SecureCookies allows toggling of the secure cookies HTTP flag

func (Config) SessionOptions

func (c Config) SessionOptions() sessions.Options

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

func (Config) SessionSecret

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

func (c Config) SessionTimeout() time.Duration

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

func (Config) Set

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

Set a specific configuration variable

func (Config) TLSCertPath

func (c Config) TLSCertPath() string

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

func (Config) TLSHost

func (c Config) TLSHost() string

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

func (Config) TLSKeyPath

func (c Config) TLSKeyPath() string

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

func (Config) TLSPort

func (c Config) TLSPort() uint16

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

type ConfigSchema

type ConfigSchema struct {
	AllowOrigins             string         `env:"ALLOW_ORIGINS" default:"http://localhost:3000,http://localhost:6688"`
	BridgeResponseURL        url.URL        `env:"BRIDGE_RESPONSE_URL"`
	ChainID                  uint64         `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"`
	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" `
	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"`
}

ConfigSchema records the schema of configuration at the type level

type Contract

type Contract struct {
	ABI abi.ABI
}

Contract holds the solidity contract's parsed ABI

func GetContract

func GetContract(name string) (*Contract, error)

GetContract loads the contract JSON file from ../evm/build/contracts and parses the ABI JSON contents into an abi.ABI object

func (*Contract) EncodeMessageCall

func (contract *Contract) EncodeMessageCall(method string, args ...interface{}) ([]byte, error)

EncodeMessageCall encodes method name and arguments into a byte array to conform with the contract's ABI

type Dialer

type Dialer interface {
	Dial(string) (CallerSubscriber, error)
}

Dialer implements Dial which is a function that creates a client for that url

type EthClient

type EthClient struct {
	CallerSubscriber
}

EthClient holds the CallerSubscriber interface for the Ethereum blockchain.

func (*EthClient) GetBlockByNumber

func (eth *EthClient) GetBlockByNumber(hex string) (models.BlockHeader, error)

GetBlockByNumber returns the block for the passed hex, or "latest", "earliest", "pending".

func (*EthClient) GetBlockNumber

func (eth *EthClient) GetBlockNumber() (uint64, error)

GetBlockNumber returns the block number of the chain head.

func (*EthClient) GetChainID

func (eth *EthClient) GetChainID() (uint64, error)

GetChainID returns the ethereum ChainID.

func (*EthClient) GetERC20Balance

func (eth *EthClient) GetERC20Balance(address common.Address, contractAddress common.Address) (*big.Int, error)

GetERC20Balance returns the balance of the given address for the token contract address.

func (*EthClient) GetEthBalance

func (eth *EthClient) GetEthBalance(address common.Address) (*assets.Eth, error)

GetEthBalance returns the balance of the given addresses in Ether.

func (*EthClient) GetLogs

func (eth *EthClient) GetLogs(q ethereum.FilterQuery) ([]models.Log, error)

GetLogs returns all logs that respect the passed filter query.

func (*EthClient) GetNonce

func (eth *EthClient) GetNonce(address common.Address) (uint64, error)

GetNonce returns the nonce (transaction count) for a given address.

func (*EthClient) GetTxReceipt

func (eth *EthClient) GetTxReceipt(hash common.Hash) (*models.TxReceipt, error)

GetTxReceipt returns the transaction receipt for the given transaction hash.

func (*EthClient) GetWeiBalance

func (eth *EthClient) GetWeiBalance(address common.Address) (*big.Int, error)

GetWeiBalance returns the balance of the given address in Wei.

func (*EthClient) SendRawTx

func (eth *EthClient) SendRawTx(hex string) (common.Hash, error)

SendRawTx sends a signed transaction to the transaction pool.

func (*EthClient) SubscribeToLogs

func (eth *EthClient) SubscribeToLogs(
	channel chan<- models.Log,
	q ethereum.FilterQuery,
) (models.EthSubscription, error)

SubscribeToLogs registers a subscription for push notifications of logs from a given address.

func (*EthClient) SubscribeToNewHeads

func (eth *EthClient) SubscribeToNewHeads(
	channel chan<- models.BlockHeader,
) (models.EthSubscription, error)

SubscribeToNewHeads registers a subscription for push notifications of new blocks.

type EthDialer

type EthDialer struct{}

EthDialer is Dialer which accesses rpc urls

func (*EthDialer) Dial

func (ed *EthDialer) Dial(urlString string) (CallerSubscriber, error)

Dial will dial the given url and return a CallerSubscriber

type EthTxManager

type EthTxManager struct {
	*EthClient
	// contains filtered or unexported fields
}

EthTxManager contains fields for the Ethereum client, the KeyStore, the local Config for the application, and the database.

func NewEthTxManager

func NewEthTxManager(ethClient *EthClient, config Config, keyStore *KeyStore, orm *orm.ORM) *EthTxManager

NewEthTxManager constructs an EthTxManager using the passed variables and initializing internal variables.

func (*EthTxManager) BumpGasUntilSafe

func (txm *EthTxManager) BumpGasUntilSafe(hash common.Hash) (*models.TxReceipt, AttemptState, error)

BumpGasUntilSafe process a collection of related TxAttempts, trying to get at least one TxAttempt into a safe state, bumping gas if needed

func (*EthTxManager) CheckAttempt

func (txm *EthTxManager) CheckAttempt(txAttempt *models.TxAttempt, blockHeight uint64) (*models.TxReceipt, AttemptState, error)

CheckAttempt retrieves a receipt for a TxAttempt, and check if it meets the minimum number of confirmations

func (*EthTxManager) Connect

func (txm *EthTxManager) Connect(bn *models.Head) error

Connect iterates over the available accounts to retrieve their nonce for client side management.

func (*EthTxManager) Connected

func (txm *EthTxManager) Connected() bool

Connected returns a bool indicating whether or not it is connected.

func (*EthTxManager) ContractLINKBalance

func (txm *EthTxManager) ContractLINKBalance(wr models.WithdrawalRequest) (assets.Link, error)

ContractLINKBalance returns the balance for the contract associated with this withdrawal request, or any errors

func (*EthTxManager) CreateTx

func (txm *EthTxManager) CreateTx(to common.Address, data []byte) (*models.Tx, error)

CreateTx signs and sends a transaction to the Ethereum blockchain.

func (*EthTxManager) CreateTxWithEth

func (txm *EthTxManager) CreateTxWithEth(from, to common.Address, value *assets.Eth) (*models.Tx, error)

CreateTxWithEth signs and sends a transaction with some ETH to transfer.

func (*EthTxManager) CreateTxWithGas

func (txm *EthTxManager) CreateTxWithGas(surrogateID null.String, to common.Address, data []byte, gasPriceWei *big.Int, gasLimit uint64) (*models.Tx, error)

CreateTxWithGas signs and sends a transaction to the Ethereum blockchain.

func (*EthTxManager) Disconnect

func (txm *EthTxManager) Disconnect()

Disconnect marks this instance as disconnected.

func (*EthTxManager) GetETHAndLINKBalances

func (txm *EthTxManager) GetETHAndLINKBalances(address common.Address) (*big.Int, *assets.Link, error)

GetETHAndLINKBalances attempts to retrieve the ethereum node's perception of the latest ETH and LINK balances for the active account on the txm, or an error on failure.

func (*EthTxManager) GetLINKBalance

func (txm *EthTxManager) GetLINKBalance(address common.Address) (*assets.Link, error)

GetLINKBalance returns the balance of LINK at the given address

func (*EthTxManager) NextActiveAccount

func (txm *EthTxManager) NextActiveAccount() *ManagedAccount

NextActiveAccount uses round robin to select a managed account from the list of available accounts as defined in Register(...)

func (*EthTxManager) OnNewHead

func (txm *EthTxManager) OnNewHead(*models.Head)

OnNewHead does nothing; exists to comply with interface.

func (*EthTxManager) Register

func (txm *EthTxManager) Register(accts []accounts.Account)

Register activates accounts for outgoing transactions and client side nonce management.

func (txm *EthTxManager) WithdrawLINK(wr models.WithdrawalRequest) (common.Hash, error)

WithdrawLINK withdraws the given amount of LINK from the contract to the configured withdrawal address. If wr.ContractAddress is empty (zero address), funds are withdrawn from configured OracleContractAddress.

type HeadTrackable

type HeadTrackable interface {
	Connect(*models.Head) error
	Disconnect()
	OnNewHead(*models.Head)
}

HeadTrackable represents any object that wishes to respond to ethereum events, after being attached to HeadTracker.

type KeyStore

type KeyStore struct {
	*keystore.KeyStore
}

KeyStore manages a key storage directory on disk.

func NewKeyStore

func NewKeyStore(keyDir string) *KeyStore

NewKeyStore creates a keystore for the given directory.

func (*KeyStore) GetAccounts

func (ks *KeyStore) GetAccounts() []accounts.Account

GetAccounts returns all accounts

func (*KeyStore) GetFirstAccount

func (ks *KeyStore) GetFirstAccount() (accounts.Account, error)

GetFirstAccount returns the unlocked account in the KeyStore object. The client ensures that an account exists during authentication.

func (*KeyStore) HasAccounts

func (ks *KeyStore) HasAccounts() bool

HasAccounts returns true if there are accounts located at the keystore directory.

func (*KeyStore) NewAccount

func (ks *KeyStore) NewAccount(passphrase string) (accounts.Account, error)

NewAccount adds an account to the keystore

func (*KeyStore) Sign

func (ks *KeyStore) Sign(input []byte) (models.Signature, error)

Sign creates an HMAC from some input data using the account's private key

func (*KeyStore) SignTx

func (ks *KeyStore) SignTx(account accounts.Account, tx *types.Transaction, chainID uint64) (*types.Transaction, error)

SignTx uses the unlocked account to sign the given transaction.

func (*KeyStore) Unlock

func (ks *KeyStore) Unlock(phrase string) error

Unlock uses the given password to try to unlock accounts located in the keystore directory.

type LogLevel

type LogLevel struct {
	zapcore.Level
}

LogLevel determines the verbosity of the events to be logged.

func (LogLevel) ForGin

func (ll LogLevel) ForGin() string

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

type ManagedAccount

type ManagedAccount struct {
	accounts.Account
	// contains filtered or unexported fields
}

ManagedAccount holds the account information alongside a client managed nonce to coordinate outgoing transactions.

func NewManagedAccount

func NewManagedAccount(a accounts.Account, nonce uint64) *ManagedAccount

NewManagedAccount creates a managed account that handles nonce increments locally.

func (*ManagedAccount) GetAndIncrementNonce

func (a *ManagedAccount) GetAndIncrementNonce(callback func(uint64) error) error

GetAndIncrementNonce will Yield the current nonce to a callback function and increment it once the callback has finished executing

func (*ManagedAccount) Nonce

func (a *ManagedAccount) Nonce() uint64

Nonce returns the client side managed nonce.

func (*ManagedAccount) ReloadNonce

func (a *ManagedAccount) ReloadNonce(txm *EthTxManager) error

ReloadNonce fetch and update the current nonce via eth_getTransactionCount

type QueuedRunChannel

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

QueuedRunChannel manages incoming results and blocks by enqueuing them in a queue per run.

func (*QueuedRunChannel) Close

func (rq *QueuedRunChannel) Close()

Close closes the QueuedRunChannel so that no runs can be added to it without throwing an error.

func (*QueuedRunChannel) Receive

func (rq *QueuedRunChannel) Receive() <-chan RunRequest

Receive returns a channel for listening to sent runs.

func (*QueuedRunChannel) Send

func (rq *QueuedRunChannel) Send(jobRunID string) error

Send adds another entry to the queue of runs.

type RunChannel

type RunChannel interface {
	Send(jobRunID string) error
	Receive() <-chan RunRequest
	Close()
}

RunChannel manages and dispatches incoming runs.

func NewQueuedRunChannel

func NewQueuedRunChannel() RunChannel

NewQueuedRunChannel initializes a QueuedRunChannel.

type RunRequest

type RunRequest struct {
	ID string
}

RunRequest is the type that the RunChannel uses to package all the necessary pieces to execute a Job Run.

type SecretGenerator

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

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

type Store

type Store struct {
	*orm.ORM
	Config      Config
	Clock       utils.AfterNower
	KeyStore    *KeyStore
	RunChannel  RunChannel
	TxManager   TxManager
	StatsPusher *synchronization.StatsPusher
}

Store contains fields for the database, Config, KeyStore, and TxManager for keeping the application state in sync with the database.

func NewStore

func NewStore(config Config) *Store

NewStore will create a new database file at the config's RootDir if it is not already present, otherwise it will use the existing db.sqlite3 file.

func NewStoreWithDialer

func NewStoreWithDialer(config Config, dialer Dialer) *Store

NewStoreWithDialer creates a new store with the given config and dialer

func (*Store) AuthorizedUserWithSession

func (s *Store) AuthorizedUserWithSession(sessionID string) (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 (*Store) Close

func (s *Store) Close() error

Close shuts down all of the working parts of the store.

func (*Store) Start

func (s *Store) Start() error

Start initiates all of Store's dependencies including the TxManager.

func (*Store) SyncDiskKeyStoreToDB

func (s *Store) SyncDiskKeyStoreToDB() error

SyncDiskKeyStoreToDB writes all keys in the keys directory to the underlying orm.

func (*Store) Unscoped

func (s *Store) Unscoped() *Store

Unscoped returns a shallow copy of the store, with an unscoped ORM allowing one to work with soft deleted records.

type TxManager

type TxManager interface {
	HeadTrackable
	Connected() bool
	Register(accounts []accounts.Account)

	CreateTx(to common.Address, data []byte) (*models.Tx, error)
	CreateTxWithGas(surrogateID null.String, to common.Address, data []byte, gasPriceWei *big.Int, gasLimit uint64) (*models.Tx, error)
	CreateTxWithEth(from, to common.Address, value *assets.Eth) (*models.Tx, error)
	CheckAttempt(txAttempt *models.TxAttempt, blockHeight uint64) (*models.TxReceipt, AttemptState, error)

	BumpGasUntilSafe(hash common.Hash) (*models.TxReceipt, AttemptState, error)

	ContractLINKBalance(wr models.WithdrawalRequest) (assets.Link, error)
	WithdrawLINK(wr models.WithdrawalRequest) (common.Hash, error)
	GetLINKBalance(address common.Address) (*assets.Link, error)
	NextActiveAccount() *ManagedAccount

	GetEthBalance(address common.Address) (*assets.Eth, error)
	SubscribeToNewHeads(channel chan<- models.BlockHeader) (models.EthSubscription, error)
	GetBlockByNumber(hex string) (models.BlockHeader, error)
	SubscribeToLogs(channel chan<- models.Log, q ethereum.FilterQuery) (models.EthSubscription, error)
	GetLogs(q ethereum.FilterQuery) ([]models.Log, error)
	GetTxReceipt(common.Hash) (*models.TxReceipt, error)
	GetChainID() (uint64, error)
}

TxManager represents an interface for interacting with the blockchain

Directories

Path Synopsis
Package models contain the key job components used by the Chainlink application.
Package models contain the key job components used by the Chainlink application.
Package presenters allow for the specification and result of a Job, its associated TaskSpecs, and every JobRun and TaskRun to be returned in a user friendly human readable format.
Package presenters allow for the specification and result of a Job, its associated TaskSpecs, and every JobRun and TaskRun to be returned in a user friendly human readable format.

Jump to

Keyboard shortcuts

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