txmgr

package
v0.0.0-...-8c125ef Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeInput

func EncodeInput(contractABI, methodName string, args ...interface{}) ([]byte, error)

EncodeInput encodes the input data according to the contract ABI

Types

type Config

type Config struct {
	// 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

	// The multiplier applied to fee suggestions to put a hard limit on fee increases.
	FeeLimitMultiplier uint64

	// TxSendTimeout is how long to wait for sending a transaction.
	// By default it is unbounded. If set, this is recommended to be at least 20 minutes.
	TxSendTimeout time.Duration

	// TxNotInMempoolTimeout is how long to wait before aborting a transaction send if the transaction does not
	// make it to the mempool. If the tx is in the mempool, TxSendTimeout is used instead.
	TxNotInMempoolTimeout time.Duration

	// NetworkTimeout is the allowed duration for a single network request.
	// This is intended to be used for network requests that can be replayed.
	NetworkTimeout 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.

func (Config) Check

func (m Config) Check() error

type SendState

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

func NewSendState

func NewSendState(safeAbortNonceTooLowCount uint64, unableToSendTimeout time.Duration) *SendState

NewSendState creates a new send state

func NewSendStateWithNow

func NewSendStateWithNow(safeAbortNonceTooLowCount uint64, unableToSendTimeout time.Duration, now func() time.Time) *SendState

NewSendStateWithNow creates a new send state with the provided clock.

func (*SendState) IsWaitingForConfirmation

func (s *SendState) IsWaitingForConfirmation() bool

IsWaitingForConfirmation returns true if we have at least one confirmation on one of our txs.

func (*SendState) ProcessSendError

func (s *SendState) ProcessSendError(err error)

ProcessSendError should be invoked with the error returned for each publication. It is safe to call this method with nil or arbitrary errors.

func (*SendState) ShouldAbortImmediately

func (s *SendState) ShouldAbortImmediately() bool

ShouldAbortImmediately returns true if the txmgr should give up on trying a given txn with the target nonce. This occurs when the set of errors recorded indicates that no further progress can be made on this transaction.

func (*SendState) TxMined

func (s *SendState) TxMined(txHash common.Hash)

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

func (s *SendState) TxNotMined(txHash common.Hash)

TxNotMined 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 SimpleTxManager

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

func NewSimpleTxManager

func NewSimpleTxManager(conf Config, chainID *big.Int, nonce *uint64, ethereumClient *ethclient.Client, from common.Address, singer gicrypto.SignerFn) (*SimpleTxManager, error)

func (*SimpleTxManager) Send

func (m *SimpleTxManager) Send(ctx context.Context, candidate TxCandidate) (*types.Receipt, error)

Send sends a candidate to the chain.

type TxCandidate

type TxCandidate struct {
	// TxData is the transaction data to be used in the constructed tx.
	TxData []byte
	// To is the recipient of the constructed tx. Nil means contract creation.
	To *common.Address
	// GasLimit is the gas limit to be used in the constructed tx.
	GasLimit uint64
	// Value is the value to be used in the constructed tx.
	Value *big.Int
}

type TxManager

type TxManager interface {
	Send(ctx context.Context, candidate TxCandidate) (*types.Receipt, error)
}

Jump to

Keyboard shortcuts

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