transactor

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 19 Imported by: 0

README

Transactor

The transactor is the component of the offchain-sdk system that manages sending transactions from 1 particular wallet.

Features

TODO

Usage

TODO

Configuraton

TODO

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// How large an individual batched tx will be (uses multicall contract if > 1).
	TxBatchSize int
	// How long to wait for a batch to be flushed (ideally 1 block time).
	TxBatchTimeout time.Duration
	// Whether we wait the full batch timeout before firing txs. False means we will fire as soon
	// as we reach the desired batch size.
	WaitFullBatchTimeout bool
	// How long to wait to retrieve txs from the queue if it is empty (ideally quick <= 1s).
	EmptyQueueDelay time.Duration
	// What the `requireSuccess` flag should be set for calls to `multicall`, if batching txs.
	MulticallRequireSuccess bool

	// Maximum duration allowed for the tx to be signed (increase this if using a remote signer)
	SignTxTimeout time.Duration

	// How long to wait for the pending nonce (ideally 1 block time).
	PendingNonceInterval time.Duration
	// How long to wait for a tx to hit the mempool and/or be confirmed by the chain.
	TxWaitingTimeout time.Duration
	// Whether we should resend txs that are stale (not confirmed after the receipt timeout).
	ResendStaleTxs bool

	// How often to post a snapshot of the transactor system status (ideally 1 block time).
	StatusUpdateInterval time.Duration

	// (Optional) SQS queue config. If left empty, an in-memory queue is used.
	SQS sqs.Config
	// If true, the queue (SQS generates its own) message ID will be used for tracking messages,
	// rather than the optional, user-provided message ID.
	UseQueueMessageID bool
}

type TxrV2

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

TxrV2 is the main transactor object. TODO: deprecate off being a job.

func NewTransactor

func NewTransactor(cfg Config, signer kmstypes.TxSigner, batcher factory.Batcher) (*TxrV2, error)

NewTransactor creates a new transactor with the given config and signer.

func (*TxrV2) Execute

func (t *TxrV2) Execute(context.Context, any) (any, error)

Execute implements job.Basic.

func (*TxrV2) ForceTxRequest

func (t *TxrV2) ForceTxRequest(ctx context.Context, txReq *types.Request) (string, error)

ForceTxRequest immediately (whenever the sender is free from any previous sends) builds and sends the tx request to the chain, after validating it. NOTE: this bypasses the queue and batching even if configured to do so.

func (*TxrV2) GetPreconfirmedState

func (t *TxrV2) GetPreconfirmedState(msgID string) types.PreconfirmedState

GetPreconfirmedState returns the status of the given message ID before it has been confirmed by the chain.

func (*TxrV2) IntervalTime

func (t *TxrV2) IntervalTime(context.Context) time.Duration

IntervalTime implements job.Polling.

func (*TxrV2) OnError

func (t *TxrV2) OnError(_ context.Context, resp *tracker.Response)

OnError is called when a transaction request fails to build or send.

func (*TxrV2) OnRevert

func (t *TxrV2) OnRevert(resp *tracker.Response, receipt *coretypes.Receipt)

OnRevert is called when a transaction has been reverted.

func (*TxrV2) OnStale

func (t *TxrV2) OnStale(ctx context.Context, resp *tracker.Response, isPending bool)

OnStale is called when a transaction becomes stale after the configured timeout.

func (*TxrV2) OnSuccess

func (t *TxrV2) OnSuccess(resp *tracker.Response, receipt *coretypes.Receipt)

OnSuccess is called when a transaction has been successfully included in a block.

func (*TxrV2) RegistryKey

func (t *TxrV2) RegistryKey() string

RegistryKey implements job.Basic.

func (*TxrV2) SendTxRequest

func (t *TxrV2) SendTxRequest(txReq *types.Request) (string, error)

SendTxRequest adds the given tx request to the tx queue, after validating it.

func (*TxrV2) Setup

func (t *TxrV2) Setup(ctx context.Context) error

Setup implements job.HasSetup.

func (*TxrV2) SubscribeTxResults

func (t *TxrV2) SubscribeTxResults(ctx context.Context, subscriber tracker.Subscriber) int

SubscribeTxResults ensures that tx results, once confirmed, are sent the given subscriber. It returns the global index of the subscription for the results.

func (*TxrV2) Teardown

func (t *TxrV2) Teardown() error

Teardown implements job.HasTeardown.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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