txm

package
v0.0.0-...-29137c7 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2025 License: MIT Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfigSet = Config{
	BroadcastChanSize: 100,
	ConfirmPollSecs:   2,

	DefaultMaxGasAmount: 200000,
	MaxSimulateAttempts: 5,

	MaxSubmitRetryAttempts: 10,
	SubmitDelayDuration:    3,
	TxExpirationSecs:       10,
	MaxTxRetryAttempts:     5,
	PruneIntervalSecs:      uint64(60 * 60 * 4),
	PruneTxExpirationSecs:  uint64(60 * 60 * 2),
}

DefaultConfigSet is the default configuration for the TransactionManager

Functions

func CreateBcsValue

func CreateBcsValue(typeTag aptos.TypeTag, typeValue any) ([]byte, error)

func CreateTypeTag

func CreateTypeTag(typeName string) (aptos.TypeTag, error)

func GetBcsValues

func GetBcsValues(data []byte, typeTags ...aptos.TypeTag) ([]any, error)

func GetContexedTxLogger

func GetContexedTxLogger(baseLogger logger.Logger, txID string, txMetadata *commontypes.TxMeta) logger.Logger

Types

type AccountStore

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

func NewAccountStore

func NewAccountStore() *AccountStore

func (*AccountStore) CreateTxStore

func (c *AccountStore) CreateTxStore(accountAddress string, initialNonce uint64) (*TxStore, error)

func (*AccountStore) GetAllUnconfirmed

func (c *AccountStore) GetAllUnconfirmed() map[string][]*UnconfirmedTx

func (*AccountStore) GetTotalInflightCount

func (c *AccountStore) GetTotalInflightCount() int

func (*AccountStore) GetTxStore

func (c *AccountStore) GetTxStore(accountAddress string) *TxStore

GetTxStore returns the TxStore for the provided account.

type AptosTx

type AptosTx struct {
	ID              string
	Metadata        *commontypes.TxMeta
	Timestamp       uint64
	FromAddress     aptos.AccountAddress
	PublicKey       ed25519.PublicKey
	ContractAddress aptos.AccountAddress
	ModuleName      string
	FunctionName    string
	TypeTags        []aptos.TypeTag
	BcsValues       [][]byte
	Attempt         uint64
	Status          commontypes.TransactionStatus
	Simulate        bool
}

type AptosTxm

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

func New

func New(lgr logger.Logger, keystore loop.Keystore, config Config, getClient func() (aptos.AptosRpcClient, error)) (*AptosTxm, error)

TODO: Config input is not validated for sanity

func (*AptosTxm) Close

func (a *AptosTxm) Close() error

func (*AptosTxm) Enqueue

func (a *AptosTxm) Enqueue(transactionID string, txMetadata *commontypes.TxMeta, fromAddress, publicKey, function string, typeArgs []string, paramTypes []string, paramValues []any, simulateTx bool) error

func (*AptosTxm) GetStatus

func (a *AptosTxm) GetStatus(transactionID string) (commontypes.TransactionStatus, error)

func (*AptosTxm) HealthReport

func (a *AptosTxm) HealthReport() map[string]error

func (*AptosTxm) InflightCount

func (a *AptosTxm) InflightCount() (int, int)

func (*AptosTxm) Name

func (a *AptosTxm) Name() string

func (*AptosTxm) Ready

func (a *AptosTxm) Ready() error

func (*AptosTxm) Start

func (a *AptosTxm) Start(ctx context.Context) error

type Config

type Config struct {
	BroadcastChanSize uint
	ConfirmPollSecs   uint

	DefaultMaxGasAmount uint64
	MaxSimulateAttempts uint

	MaxSubmitRetryAttempts uint
	SubmitDelayDuration    uint
	TxExpirationSecs       uint64
	MaxTxRetryAttempts     uint64
	PruneIntervalSecs      uint64
	PruneTxExpirationSecs  uint64
}

TODO: these should be duration, not numbers

type RetryReason

type RetryReason int
const (
	RetryReasonOutOfGas RetryReason = iota
	RetryReasonExpired
)

func (RetryReason) String

func (r RetryReason) String() string

type TxStore

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

TxStore tracks broadcast & unconfirmed txs per account address per chain id

func NewTxStore

func NewTxStore(initialNonce uint64) *TxStore

func (*TxStore) AddUnconfirmed

func (s *TxStore) AddUnconfirmed(nonce uint64, hash string, expirationTimestampSecs uint64, tx *AptosTx) error

func (*TxStore) Confirm

func (s *TxStore) Confirm(nonce uint64, hash string, failed bool) error

func (*TxStore) GetLastResyncedNonce

func (s *TxStore) GetLastResyncedNonce() uint64

func (*TxStore) GetNextNonce

func (s *TxStore) GetNextNonce() uint64

func (*TxStore) GetUnconfirmed

func (s *TxStore) GetUnconfirmed() []*UnconfirmedTx

func (*TxStore) InflightCount

func (s *TxStore) InflightCount() int

func (*TxStore) ResyncNonce

func (s *TxStore) ResyncNonce(onchainNonce uint64)

Resync the next nonce. This should never be called between GetNextNonce() and AddUnconfirmed() as it updates the next nonce, since AddUnconfirmed expects the current `nextNonce` to be used for the following transaction.

type UnconfirmedTx

type UnconfirmedTx struct {
	Nonce                   uint64
	Hash                    string
	ExpirationTimestampSecs uint64
	Tx                      *AptosTx
}

Jump to

Keyboard shortcuts

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