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 ¶
- Variables
- type ActiveAccount
- type AfterNower
- type CallerSubscriber
- type Clock
- type Config
- type Dialer
- type Duration
- type EthClient
- func (eth *EthClient) GetBlockByNumber(hex string) (models.BlockHeader, error)
- func (eth *EthClient) GetBlockNumber() (uint64, error)
- func (eth *EthClient) GetERC20Balance(address common.Address, contractAddress common.Address) (*big.Int, error)
- func (eth *EthClient) GetEthBalance(address common.Address) (*assets.Eth, error)
- func (eth *EthClient) GetLogs(q ethereum.FilterQuery) ([]types.Log, error)
- func (eth *EthClient) GetNonce(address common.Address) (uint64, error)
- func (eth *EthClient) GetTxReceipt(hash common.Hash) (*TxReceipt, error)
- func (eth *EthClient) GetWeiBalance(address common.Address) (*big.Int, error)
- func (eth *EthClient) SendRawTx(hex string) (common.Hash, error)
- func (eth *EthClient) SubscribeToLogs(channel chan<- types.Log, q ethereum.FilterQuery) (models.EthSubscription, error)
- func (eth *EthClient) SubscribeToNewHeads(channel chan<- models.BlockHeader) (models.EthSubscription, error)
- type EthDialer
- type KeyStore
- func (ks *KeyStore) GetAccount() (accounts.Account, error)
- func (ks *KeyStore) HasAccounts() bool
- func (ks *KeyStore) Sign(input []byte) (models.Signature, error)
- func (ks *KeyStore) SignTx(tx *types.Transaction, chainID uint64) (*types.Transaction, error)
- func (ks *KeyStore) Unlock(phrase string) error
- type LogLevel
- type QueuedRunChannel
- type RunChannel
- type RunRequest
- type SecretGenerator
- type Store
- type TxManager
- func (txm *TxManager) ActivateAccount(account accounts.Account) error
- func (txm *TxManager) CreateTx(to common.Address, data []byte) (*models.Tx, error)
- func (txm *TxManager) GetActiveAccount() *ActiveAccount
- func (txm *TxManager) GetLinkBalance(address common.Address) (*assets.Link, error)
- func (txm *TxManager) MeetsMinConfirmations(hash common.Hash) (bool, error)
- func (txm *TxManager) WithdrawLink(wr models.WithdrawalRequest) (common.Hash, error)
- type TxReceipt
Constants ¶
This section is empty.
Variables ¶
var Sha = "unset"
Sha string "unset"
var Version = "unset"
Version the version of application
Functions ¶
This section is empty.
Types ¶
type ActiveAccount ¶
ActiveAccount holds the account information alongside a client managed nonce to coordinate outgoing transactions.
func (*ActiveAccount) GetAndIncrementNonce ¶
func (a *ActiveAccount) 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 (*ActiveAccount) GetNonce ¶
func (a *ActiveAccount) GetNonce() uint64
GetNonce returns the client side managed nonce.
type AfterNower ¶
AfterNower is an interface that fulfills the `After()` and `Now()` methods.
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 Clock ¶
type Clock struct{}
Clock is a basic type for scheduling events in the application.
type Config ¶
type Config struct { AllowOrigins string `env:"ALLOW_ORIGINS" envDefault:"http://localhost:3000,http://localhost:6688"` ChainID uint64 `env:"ETH_CHAIN_ID" envDefault:"0"` ClientNodeURL string `env:"CLIENT_NODE_URL" envDefault:"http://localhost:6688"` DatabaseTimeout Duration `env:"DATABASE_TIMEOUT" envDefault:"500ms"` Dev bool `env:"CHAINLINK_DEV" envDefault:"false"` EthGasBumpThreshold uint64 `env:"ETH_GAS_BUMP_THRESHOLD" envDefault:"12"` EthGasBumpWei big.Int `env:"ETH_GAS_BUMP_WEI" envDefault:"5000000000"` EthGasPriceDefault big.Int `env:"ETH_GAS_PRICE_DEFAULT" envDefault:"20000000000"` EthereumURL string `env:"ETH_URL" envDefault:"ws://localhost:8546"` LinkContractAddress string `env:"LINK_CONTRACT_ADDRESS" envDefault:"0x514910771AF9Ca656af840dff83E8264EcF986CA"` LogLevel LogLevel `env:"LOG_LEVEL" envDefault:"info"` MinIncomingConfirmations uint64 `env:"MIN_INCOMING_CONFIRMATIONS" envDefault:"0"` MinOutgoingConfirmations uint64 `env:"MIN_OUTGOING_CONFIRMATIONS" envDefault:"12"` MinimumContractPayment assets.Link `env:"MINIMUM_CONTRACT_PAYMENT" envDefault:"1000000000000000000"` MinimumRequestExpiration uint64 `env:"MINIMUM_REQUEST_EXPIRATION" envDefault:"300"` OracleContractAddress *common.Address `env:"ORACLE_CONTRACT_ADDRESS"` Port uint16 `env:"CHAINLINK_PORT" envDefault:"6688"` TLSPort uint16 `env:"CHAINLINK_TLS_PORT" envDefault:"6689"` TLSHost string `env:"CHAINLINK_TLS_HOST" envDefault:""` RootDir string `env:"ROOT" envDefault:"~/.chainlink"` SecretGenerator SecretGenerator TLSCertPath string `env:"TLS_CERT_PATH" envDefault:""` TLSKeyPath string `env:"TLS_KEY_PATH" envDefault:""` SessionTimeout Duration `env:"SESSION_TIMEOUT" envDefault:"15m"` ReaperExpiration Duration `env:"REAPER_EXPIRATION" envDefault:"240h"` }
Config holds parameters used by the application which can be overridden by setting environment variables.
func NewConfig ¶
func NewConfig() Config
NewConfig returns the config with the environment variables set to their respective fields, or defaults if not present.
func (Config) CreateProductionLogger ¶
CreateProductionLogger returns a custom logger for the config's root directory and LogLevel, with pretty printing for stdout.
func (Config) SessionOptions ¶
SessionOptions returns the sesssions.Options struct used to configure the session store.
func (Config) SessionSecret ¶
SessionSecret returns a sequence of bytes to be used as a private key for session signing or encryption.
type Dialer ¶
type Dialer interface {
Dial(string) (CallerSubscriber, error)
}
Dialer implements Dial which is a function that creates a client for that url
type Duration ¶
Duration returns a time duration with the supported units of "ns", "us", "ms", "s", "m", "h".
func (Duration) MarshalText ¶
MarshalText returns the byte slice of the formatted duration e.g. "500ms"
func (*Duration) UnmarshalText ¶
UnmarshalText parses the time.Duration and assigns it
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 ¶
GetBlockNumber returns the block number of the chain head.
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 ¶
GetEthBalance returns the balance of the given addresses in Ether.
func (*EthClient) GetTxReceipt ¶
GetTxReceipt returns the transaction receipt for the given transaction hash.
func (*EthClient) GetWeiBalance ¶
GetWeiBalance returns the balance of the given address in Wei.
func (*EthClient) SubscribeToLogs ¶
func (eth *EthClient) SubscribeToLogs( channel chan<- types.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 KeyStore ¶
KeyStore manages a key storage directory on disk.
func NewKeyStore ¶
NewKeyStore creates a keystore for the given directory.
func (*KeyStore) GetAccount ¶
GetAccount 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) SignTx ¶
func (ks *KeyStore) SignTx(tx *types.Transaction, chainID uint64) (*types.Transaction, error)
SignTx uses the unlocked account to sign the given transaction.
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(rr models.RunResult, ibn *models.IndexableBlockNumber) error
Send adds another entry to the queue of runs.
type RunChannel ¶
type RunChannel interface { Send(rr models.RunResult, ibn *models.IndexableBlockNumber) 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 { Input models.RunResult BlockNumber *models.IndexableBlockNumber }
RunRequest is the type that the RunChannel uses to package all the necessary pieces to execute a Job Run.
type SecretGenerator ¶
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 AfterNower KeyStore *KeyStore RunChannel RunChannel TxManager *TxManager // contains filtered or unexported fields }
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.bolt 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.
type TxManager ¶
type TxManager struct { *EthClient // contains filtered or unexported fields }
TxManager contains fields for the Ethereum client, the KeyStore, the local Config for the application, and the database.
func (*TxManager) ActivateAccount ¶
ActivateAccount retrieves an account's nonce from the blockchain for client side management in ActiveAccount.
func (*TxManager) GetActiveAccount ¶
func (txm *TxManager) GetActiveAccount() *ActiveAccount
GetActiveAccount returns a copy of the TxManager's active nonce managed account.
func (*TxManager) GetLinkBalance ¶
GetLinkBalance returns the balance of LINK at the given address
func (*TxManager) MeetsMinConfirmations ¶
MeetsMinConfirmations returns true if the given transaction hash has been confirmed on the blockchain.
func (*TxManager) WithdrawLink ¶
WithdrawLink withdraws the given amount of LINK from the contract to the configured withdrawal address
type TxReceipt ¶
type TxReceipt struct { BlockNumber *models.Int `json:"blockNumber"` Hash common.Hash `json:"transactionHash"` }
TxReceipt holds the block number and the transaction hash of a signed transaction that has been written to the blockchain.
func (*TxReceipt) Unconfirmed ¶
Unconfirmed returns true if the transaction is not confirmed.
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. |