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.
EthCallerSubscriber ¶
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
- Variables
- type AttemptState
- type CallArgs
- type CallerSubscriber
- type Contract
- type Dialer
- type EthCallerSubscriber
- func (eth *EthCallerSubscriber) GetBlockByNumber(hex string) (models.BlockHeader, error)
- func (eth *EthCallerSubscriber) GetChainID() (*big.Int, error)
- func (eth *EthCallerSubscriber) GetERC20Balance(address common.Address, contractAddress common.Address) (*big.Int, error)
- func (eth *EthCallerSubscriber) GetEthBalance(address common.Address) (*assets.Eth, error)
- func (eth *EthCallerSubscriber) GetLogs(q ethereum.FilterQuery) ([]models.Log, error)
- func (eth *EthCallerSubscriber) GetNonce(address common.Address) (uint64, error)
- func (eth *EthCallerSubscriber) GetTxReceipt(hash common.Hash) (*models.TxReceipt, error)
- func (eth *EthCallerSubscriber) SendRawTx(hex string) (common.Hash, error)
- func (eth *EthCallerSubscriber) SubscribeToLogs(channel chan<- models.Log, q ethereum.FilterQuery) (models.EthSubscription, error)
- func (eth *EthCallerSubscriber) SubscribeToNewHeads(channel chan<- models.BlockHeader) (models.EthSubscription, error)
- type EthClient
- type EthDialer
- type EthTxManager
- func (txm *EthTxManager) BumpGasUntilSafe(hash common.Hash) (*models.TxReceipt, AttemptState, error)
- func (txm *EthTxManager) CheckAttempt(txAttempt *models.TxAttempt, blockHeight uint64) (*models.TxReceipt, AttemptState, error)
- func (txm *EthTxManager) Connect(bn *models.Head) error
- func (txm *EthTxManager) Connected() bool
- func (txm *EthTxManager) ContractLINKBalance(wr models.WithdrawalRequest) (assets.Link, error)
- func (txm *EthTxManager) CreateTx(to common.Address, data []byte) (*models.Tx, error)
- func (txm *EthTxManager) CreateTxWithEth(from, to common.Address, value *assets.Eth) (*models.Tx, error)
- func (txm *EthTxManager) CreateTxWithGas(surrogateID null.String, to common.Address, data []byte, gasPriceWei *big.Int, ...) (*models.Tx, error)
- func (txm *EthTxManager) Disconnect()
- func (txm *EthTxManager) GetETHAndLINKBalances(address common.Address) (*assets.Eth, *assets.Link, error)
- func (txm *EthTxManager) GetLINKBalance(address common.Address) (*assets.Link, error)
- func (txm *EthTxManager) NextActiveAccount() *ManagedAccount
- func (txm *EthTxManager) OnNewHead(head *models.Head)
- func (txm *EthTxManager) Register(accts []accounts.Account)
- func (txm *EthTxManager) WithdrawLINK(wr models.WithdrawalRequest) (common.Hash, error)
- type HeadTrackable
- type KeyStore
- func (ks *KeyStore) GetAccounts() []accounts.Account
- func (ks *KeyStore) GetFirstAccount() (accounts.Account, error)
- func (ks *KeyStore) HasAccounts() bool
- func (ks *KeyStore) NewAccount(passphrase string) (accounts.Account, error)
- func (ks *KeyStore) Sign(input []byte) (models.Signature, error)
- func (ks *KeyStore) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
- func (ks *KeyStore) Unlock(phrase string) error
- type ManagedAccount
- type QueuedRunChannel
- type RunChannel
- type RunRequest
- type Store
- type TxManager
Constants ¶
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 ¶
var ErrPendingConnection = errors.New("Cannot talk to chain, pending connection")
ErrPendingConnection is the error returned if TxManager is not connected.
var Sha = "unset"
Sha string "unset"
var Version = "unset"
Version the version of application
Functions ¶
This section is empty.
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 CallArgs ¶ added in v0.6.6
CallArgs represents the data used to call the balance method of an ERC contract. "To" is the address of the ERC contract. "Data" is the message sent to the contract.
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 Contract ¶
Contract holds the solidity contract's parsed ABI
func GetContract ¶
GetContract loads the contract JSON file from ../evm/build/contracts and parses the ABI JSON contents into an abi.ABI object
type Dialer ¶
type Dialer interface {
Dial(string) (CallerSubscriber, error)
}
Dialer implements Dial which is a function that creates a client for that url
type EthCallerSubscriber ¶ added in v0.6.6
type EthCallerSubscriber struct {
CallerSubscriber
}
EthCallerSubscriber holds the CallerSubscriber interface for the Ethereum blockchain.
func (*EthCallerSubscriber) GetBlockByNumber ¶ added in v0.6.6
func (eth *EthCallerSubscriber) GetBlockByNumber(hex string) (models.BlockHeader, error)
GetBlockByNumber returns the block for the passed hex, or "latest", "earliest", "pending".
func (*EthCallerSubscriber) GetChainID ¶ added in v0.6.6
func (eth *EthCallerSubscriber) GetChainID() (*big.Int, error)
GetChainID returns the ethereum ChainID.
func (*EthCallerSubscriber) GetERC20Balance ¶ added in v0.6.6
func (eth *EthCallerSubscriber) GetERC20Balance(address common.Address, contractAddress common.Address) (*big.Int, error)
GetERC20Balance returns the balance of the given address for the token contract address.
func (*EthCallerSubscriber) GetEthBalance ¶ added in v0.6.6
GetEthBalance returns the balance of the given addresses in Ether.
func (*EthCallerSubscriber) GetLogs ¶ added in v0.6.6
func (eth *EthCallerSubscriber) GetLogs(q ethereum.FilterQuery) ([]models.Log, error)
GetLogs returns all logs that respect the passed filter query.
func (*EthCallerSubscriber) GetNonce ¶ added in v0.6.6
func (eth *EthCallerSubscriber) GetNonce(address common.Address) (uint64, error)
GetNonce returns the nonce (transaction count) for a given address.
func (*EthCallerSubscriber) GetTxReceipt ¶ added in v0.6.6
GetTxReceipt returns the transaction receipt for the given transaction hash.
func (*EthCallerSubscriber) SendRawTx ¶ added in v0.6.6
func (eth *EthCallerSubscriber) SendRawTx(hex string) (common.Hash, error)
SendRawTx sends a signed transaction to the transaction pool.
func (*EthCallerSubscriber) SubscribeToLogs ¶ added in v0.6.6
func (eth *EthCallerSubscriber) 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 (*EthCallerSubscriber) SubscribeToNewHeads ¶ added in v0.6.6
func (eth *EthCallerSubscriber) SubscribeToNewHeads( channel chan<- models.BlockHeader, ) (models.EthSubscription, error)
SubscribeToNewHeads registers a subscription for push notifications of new blocks.
type EthClient ¶
type EthClient interface { GetNonce(address common.Address) (uint64, error) GetEthBalance(address common.Address) (*assets.Eth, error) GetERC20Balance(address common.Address, contractAddress common.Address) (*big.Int, error) SendRawTx(hex string) (common.Hash, error) GetTxReceipt(hash common.Hash) (*models.TxReceipt, error) GetBlockByNumber(hex string) (models.BlockHeader, error) GetLogs(q ethereum.FilterQuery) ([]models.Log, error) GetChainID() (*big.Int, error) SubscribeToLogs(channel chan<- models.Log, q ethereum.FilterQuery) (models.EthSubscription, error) SubscribeToNewHeads(channel chan<- models.BlockHeader) (models.EthSubscription, error) }
EthClient is the interface supplied by EthCallerSubscriber
type EthDialer ¶
type EthDialer struct {
// contains filtered or unexported fields
}
EthDialer is Dialer which accesses rpc urls
func NewEthDialer ¶ added in v0.6.6
NewEthDialer returns an eth dialer with the specified rate limit
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(client EthClient, config orm.ConfigReader, 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) 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) (*assets.Eth, *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 ¶
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(head *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 (*EthTxManager) WithdrawLINK ¶
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 ¶
HeadTrackable represents any object that wishes to respond to ethereum events, after being attached to HeadTracker.
type KeyStore ¶
KeyStore manages a key storage directory on disk.
func NewKeyStore ¶
NewKeyStore creates a keystore for the given directory.
func (*KeyStore) GetAccounts ¶
GetAccounts returns all accounts
func (*KeyStore) GetFirstAccount ¶
GetFirstAccount returns the unlocked account in the KeyStore object. The client ensures that an account exists during authentication.
func (*KeyStore) HasAccounts ¶
HasAccounts returns true if there are accounts located at the keystore directory.
func (*KeyStore) NewAccount ¶
NewAccount adds an account to the keystore
type ManagedAccount ¶
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.
type RunChannel ¶
type RunChannel interface { Send(jobRunID *models.ID) error Receive() <-chan RunRequest Close() }
RunChannel manages and dispatches incoming runs.
func NewQueuedRunChannel ¶
func NewQueuedRunChannel() RunChannel
NewQueuedRunChannel initializes a QueuedRunChannel.
type RunRequest ¶
RunRequest is the type that the RunChannel uses to package all the necessary pieces to execute a Job Run.
type Store ¶
type Store struct { *orm.ORM Config *orm.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 ¶
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 ¶
NewStoreWithDialer creates a new store with the given config and dialer
func (*Store) AuthorizedUserWithSession ¶
AuthorizedUserWithSession will return the one API user if the Session ID exists and hasn't expired, and update session's LastUsed field.
func (*Store) SyncDiskKeyStoreToDB ¶
SyncDiskKeyStoreToDB writes all keys in the keys directory to the underlying orm.
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() (*big.Int, error) }
TxManager represents an interface for interacting with the blockchain
Source Files ¶
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. |