txm

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfigSet = Config{
	BroadcastChanSize:    100,
	ConfirmPollInterval:  config.MustNewDuration(5 * time.Second),
	SendRetryDelay:       config.MustNewDuration(3 * time.Second),
	MaxSendRetryAttempts: 5,
	TxExpiration:         config.MustNewDuration(5 * time.Minute),
	CleanupInterval:      config.MustNewDuration(60 * time.Minute),
	SendTimeout:          config.MustNewDuration(30 * time.Second),
	TraceTimeout:         config.MustNewDuration(60 * time.Second),
	EnableTraceLogging:   ptr(true),
}

Functions

This section is empty.

Types

type AccountStore

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

func NewAccountStore

func NewAccountStore() *AccountStore

func (*AccountStore) CleanupAll

func (c *AccountStore) CleanupAll(currentTimeMs uint64) (finalizedLTs []uint64, expiredLTs []uint64)

CleanupAll removes finalized and expired transactions from all TxStores. Returns the LTs of finalized and expired transactions that were removed.

func (*AccountStore) GetAllUnconfirmed

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

GetAllUnconfirmed returns a map from account address to their list of unconfirmed transactions.

func (*AccountStore) GetTotalInflightCount

func (c *AccountStore) GetTotalInflightCount() int

GetTotalInflightCount returns the total count of unconfirmed txs across all accounts.

func (*AccountStore) GetTxStore

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

GetTxStore returns the TxStore for an account, creating it if missing.

type Config

type Config struct {
	BroadcastChanSize    uint             // Size of the broadcast queue
	ConfirmPollInterval  *config.Duration // Interval to poll for transaction confirmations
	SendRetryDelay       *config.Duration // Delay between send retry attempts
	MaxSendRetryAttempts uint             // Max retries before giving up broadcasting
	TxExpiration         *config.Duration // Time after which an unconfirmed transaction is considered expired
	CleanupInterval      *config.Duration // Interval to clean up finalized and expired transactions
	SendTimeout          *config.Duration // Timeout for each SendWaitTransaction call to prevent hanging
	TraceTimeout         *config.Duration // Timeout for each WaitForTrace call to prevent hanging
	EnableTraceLogging   *bool            // Whether to gather and log full transaction traces for debugging
}

Config holds configuration parameters for the Transaction Manager. NOTE: when adding new fields, please update ApplyDefaults, DefaultConfigSet, and ValidateConfig accordingly. Also check toml_test.go TestNewDecodedTOMLConfig() to ensure new fields are tested there.

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

func (*Config) ValidateConfig

func (c *Config) ValidateConfig() (err error)

type FinalizedTx

type FinalizedTx struct {
	TotalActionFees *big.Int
	ExitCode        tvm.ExitCode
	TraceSucceeded  bool
}

type Request

type Request struct {
	Mode            uint8           // Send mode for TON message
	FromWallet      wallet.Wallet   // Source wallet address
	ContractAddress address.Address // Destination contract or wallet address
	Body            *cell.Cell      // Encoded message body (method + params)
	Amount          tlb.Coins       // Amount in nanotons
	Bounce          bool            // Bounce on error (TON message flag)
	StateInit       *cell.Cell      // Optional: contract deploy init
	ID              *string         // Optional: unique ID for transaction tracking
}

type Tx

type Tx struct {
	Mode            uint8                         // send mode bitmask, controls how the TON message is processed
	From            address.Address               // wallet used to send the message
	To              address.Address               // destination address
	Amount          tlb.Coins                     // amount to send
	Body            *cell.Cell                    // optional body to attach
	StateInit       *cell.Cell                    // optional, for deploying new contracts
	Bounceable      bool                          // whether the destination is bounceable
	CreatedAt       time.Time                     // when the tx was first enqueued
	BroadcastAt     time.Time                     // when the tx was successfully broadcasted
	FinalizedAt     time.Time                     // when the message status is finalized
	Expiration      time.Time                     // expiration timestamp based on TTL
	ReceivedMessage tracetracking.ReceivedMessage // received message
	ID              *string                       // optional: unique ID for transaction tracking
}

type TxManager

type TxManager interface {
	services.Service
	Enqueue(request Request) error
	GetTransactionStatus(ctx context.Context, lt uint64) (commontypes.TransactionStatus, tvm.ExitCode, tlb.Coins, error)
	GetClient(ctx context.Context) (tracetracking.SignedAPIClient, error)
	InflightCount() (int, int)
}

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() *TxStore

func (*TxStore) AddUnconfirmed

func (s *TxStore) AddUnconfirmed(lt uint64, expirationMs uint64, tx *Tx) error

AddUnconfirmed adds a new unconfirmed transaction by lamport time.

func (*TxStore) GetTxState

func (s *TxStore) GetTxState(lt uint64) (tracetracking.MsgStatus, bool, tvm.ExitCode, tlb.Coins, bool)

GetTxState returns the message status, whether the transaction trace succeeded, the exit code, and whether the transaction was found at all. - MsgStatus indicates the lifecycle state of the message. - isSucceeded indicates whether the transaction trace execution succeeded. - ExitCode contains the VM result code. - Coins represents the Total Action Fees associated with the transaction. - found tells whether the transaction was present in memory.

func (*TxStore) GetUnconfirmed

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

GetUnconfirmed returns all unconfirmed transactions sorted by expiration time ascending.

func (*TxStore) InflightCount

func (s *TxStore) InflightCount() int

func (*TxStore) MarkFinalized

func (s *TxStore) MarkFinalized(lt uint64, success bool, exitCode tvm.ExitCode) error

Confirm marks a transaction as confirmed and removes it by LT.

type Txm

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

func New

func New(
	lggr logger.Logger,
	chainID string,
	keystore loop.Keystore,
	clientProvider func(context.Context) (tracetracking.SignedAPIClient, error),
	config Config,
) (*Txm, error)

func (*Txm) Close

func (t *Txm) Close() error

func (*Txm) Enqueue

func (t *Txm) Enqueue(request Request) error

Enqueues a transaction for broadcasting.

func (*Txm) GetClient

func (t *Txm) GetClient(ctx context.Context) (tracetracking.SignedAPIClient, error)

func (*Txm) GetTransactionStatus

func (t *Txm) GetTransactionStatus(ctx context.Context, lt uint64) (commontypes.TransactionStatus, tvm.ExitCode, tlb.Coins, error)

GetTransactionStatus translates internal TON transaction state to chainlink common statuses.

func (*Txm) HealthReport

func (t *Txm) HealthReport() map[string]error

func (*Txm) InflightCount

func (t *Txm) InflightCount() (int, int)

func (*Txm) Name

func (t *Txm) Name() string

func (*Txm) Ready

func (t *Txm) Ready() error

func (*Txm) Start

func (t *Txm) Start(ctx context.Context) error

type UnconfirmedTx

type UnconfirmedTx struct {
	LT           uint64
	ExpirationMs uint64
	Tx           *Tx
}

Jump to

Keyboard shortcuts

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