Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCouldNotGetReceipt is the error string we save if we reach our finality depth for a confirmed transaction without ever getting a receipt // This most likely happened because an external wallet used the account for this nonce ErrCouldNotGetReceipt = "could not get receipt" )
Functions ¶
func BumpGas ¶
BumpGas computes the next gas price to attempt as the largest of: - A configured percentage bump (GasBumpPercent) on top of the baseline price. - A configured fixed amount of Wei (GasBumpWei) on top of the baseline price. The baseline price is the maximum of the previous gas price attempt and TxManager's current gas price.
func WrapIfError ¶
WrapIfError decorates an error with the given message. It is intended to be used with `defer` statements, like so:
func SomeFunction() (err error) { defer WrapIfError(&err, "error in SomeFunction:") ... }
Types ¶
type StartStopOnce ¶
func (*StartStopOnce) OkayToStart ¶
func (once *StartStopOnce) OkayToStart() (ok bool)
func (*StartStopOnce) OkayToStop ¶
func (once *StartStopOnce) OkayToStop() (ok bool)
func (*StartStopOnce) StartOnce ¶
func (once *StartStopOnce) StartOnce(name string, fn func() error) error
func (*StartStopOnce) State ¶
func (once *StartStopOnce) State() StartStopOnceState
type StartStopOnceState ¶
type StartStopOnceState int
const ( StartStopOnce_Unstarted StartStopOnceState = iota StartStopOnce_Started StartStopOnce_Stopped )
type TxBroadcaster ¶
type TxBroadcaster interface { RegisterAccount(address gethCommon.Address) error AddTx(txID uuid.UUID, from gethCommon.Address, to gethCommon.Address, value *big.Int, encodedPayload []byte, gasLimit uint64, ) error Start() error Stop() error Trigger() ProcessUnstartedTxs(account *models.Account) error }
TxBroadcaster monitors transactions that need to be broadcast, assigns nonces and ensures that at least one eth node somewhere has received the transaction successfully.
This does not guarantee delivery! A whole host of other things can subsequently go wrong such as transactions being evicted from the mempool, eth nodes going offline etc. Responsibility for ensuring eventual inclusion into the chain falls on the shoulders of the TxConfirmer.
What TxBroadcaster does guarantee is: - a monotonic series of increasing nonces for txs that can all eventually be confirmed if you retry enough times - transition of txs out of unstarted into either fatal_error or unconfirmed - existence of a saved tx_attempt
func NewTxBroadcaster ¶
func NewTxBroadcaster( ethClient client.Client, store store.Store, keyStore client.KeyStoreInterface, config *types.Config) TxBroadcaster
NewTxBroadcaster returns a new concrete TxBroadcaster
type TxConfirmer ¶
type TxConfirmer interface { subscription.HeadTrackable // Methods for testing CheckForReceipts(ctx context.Context, blockNum int64) error BumpGasWhereNecessary(ctx context.Context, accounts []*models.Account, blockHeight int64) error EnsureConfirmedTxsInLongestChain(ctx context.Context, accounts []*models.Account, head *models.Head) error SetKeyStore(keyStore client.KeyStoreInterface) }
func NewTxConfirmer ¶
func NewTxConfirmer( ethClient client.Client, store esStore.Store, keyStore client.KeyStoreInterface, config *types.Config) TxConfirmer
type TxManager ¶
type TxManager interface { Start() error RegisterAccount(address gethCommon.Address) error AddTx( from gethCommon.Address, to gethCommon.Address, value *big.Int, encodedPayload []byte, gasLimit uint64, ) (uuid.UUID, error) GetTx(txID uuid.UUID) (*models.Tx, error) GetTxAttempt(attemptID uuid.UUID) (*models.TxAttempt, error) GetTxReceipt(receiptID uuid.UUID) (*models.TxReceipt, error) IsTxConfirmedAtOrBeforeBlockNumber(txID uuid.UUID, blockNumber int64) (bool, error) AddJob(txID uuid.UUID, metadata []byte) (uuid.UUID, error) MonitorJob(jobID uuid.UUID, handler JobHandler) DeleteJob(jobID uuid.UUID) error GetUnhandledJobIDs() ([]uuid.UUID, error) }