Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcGasFeeCap ¶
CalcGasFeeCap deterministically computes the recommended gas fee cap given the base fee and gasTipCap. The resulting gasFeeCap is equal to:
gasTipCap + 2*baseFee.
func WaitMined ¶
func WaitMined( ctx context.Context, backend ReceiptSource, tx *types.Transaction, queryInterval time.Duration, numConfirmations uint64, ) (*types.Receipt, error)
WaitMined blocks until the backend indicates confirmation of tx and returns the tx receipt. Queries are made every queryInterval, regardless of whether the backend returns an error. This method can be canceled using the passed context.
Types ¶
type Config ¶
type Config struct { // Log is a local logging instance. Log log.Logger // Name the name of the driver to appear in log lines. Name string // ResubmissionTimeout is the interval at which, if no previously // published transaction has been mined, the new tx with a bumped gas // price will be published. Only one publication at MaxGasPrice will be // attempted. ResubmissionTimeout time.Duration // RequireQueryInterval is the interval at which the tx manager will // query the backend to check for confirmations after a tx at a // specific gas price has been published. ReceiptQueryInterval time.Duration // NumConfirmations specifies how many blocks are need to consider a // transaction confirmed. NumConfirmations uint64 // SafeAbortNonceTooLowCount specifies how many ErrNonceTooLow observations // are required to give up on a tx at a particular nonce without receiving // confirmation. SafeAbortNonceTooLowCount uint64 }
Config houses parameters for altering the behavior of a SimpleTxManager.
type ReceiptSource ¶
type ReceiptSource interface { // BlockNumber returns the most recent block number. BlockNumber(ctx context.Context) (uint64, error) // TransactionReceipt queries the backend for a receipt associated with // txHash. If lookup does not fail, but the transaction is not found, // nil should be returned for both values. TransactionReceipt( ctx context.Context, txHash common.Hash) (*types.Receipt, error) }
ReceiptSource is a minimal function signature used to detect the confirmation of published txs.
NOTE: This is a subset of bind.DeployBackend.
type SendState ¶
type SendState struct {
// contains filtered or unexported fields
}
SendState tracks information about the publication state of a given txn. In this context, a txn may correspond to multiple different txn hashes due to varying gas prices, though we treat them all as the same logical txn. This struct is primarily used to determine whether or not the txmgr should abort a given txn and retry with a higher nonce.
func NewSendState ¶
NewSendState parameterizes a new SendState from the passed safeAbortNonceTooLowCount.
func (*SendState) IsWaitingForConfirmation ¶
IsWaitingForConfirmation returns true if we have at least one confirmation on one of our txs.
func (*SendState) ProcessSendError ¶
ProcessSendError should be invoked with the error returned for each publication. It is safe to call this method with nil or arbitrary errors. Currently it only acts on errors containing the ErrNonceTooLow message.
func (*SendState) ShouldAbortImmediately ¶
ShouldAbortImmediately returns true if the txmgr should give up on trying a given txn with the target nonce. For now, this only happens if we see an extended period of getting ErrNonceTooLow without having a txn mined.
func (*SendState) TxMined ¶
TxMined records that the txn with txnHash has been mined and is await confirmation. It is safe to call this function multiple times.
func (*SendState) TxNotMined ¶
TxMined records that the txn with txnHash has not been mined or has been reorg'd out. It is safe to call this function multiple times.
type SendTransactionFunc ¶
type SendTransactionFunc = func(ctx context.Context, tx *types.Transaction) error
type SimpleTxManager ¶
type SimpleTxManager struct {
// contains filtered or unexported fields
}
SimpleTxManager is a implementation of TxManager that performs linear fee bumping of a tx until it confirms.
func NewSimpleTxManager ¶
func NewSimpleTxManager( name string, cfg Config, backend ReceiptSource) *SimpleTxManager
NewSimpleTxManager initializes a new SimpleTxManager with the passed Config.
func (*SimpleTxManager) Send ¶
func (m *SimpleTxManager) Send( ctx context.Context, updateGasPrice UpdateGasPriceFunc, sendTx SendTransactionFunc, ) (*types.Receipt, error)
Send is used to publish a transaction with incrementally higher gas prices until the transaction eventually confirms. This method blocks until an invocation of sendTx returns (called with differing gas prices). The method may be canceled using the passed context.
NOTE: Send should be called by AT MOST one caller at a time.
type TxManager ¶
type TxManager interface { // Send is used to publish a transaction with incrementally higher gas // prices until the transaction eventually confirms. This method blocks // until an invocation of sendTx returns (called with differing gas // prices). The method may be canceled using the passed context. // // NOTE: Send should be called by AT MOST one caller at a time. Send( ctx context.Context, updateGasPrice UpdateGasPriceFunc, sendTxn SendTransactionFunc, ) (*types.Receipt, error) }
TxManager is an interface that allows callers to reliably publish txs, bumping the gas price if needed, and obtain the receipt of the resulting tx.
type UpdateGasPriceFunc ¶
type UpdateGasPriceFunc = func(ctx context.Context) (*types.Transaction, error)
UpdateGasPriceSendTxFunc defines a function signature for publishing a desired tx with a specific gas price. Implementations of this signature should also return promptly when the context is canceled.