txm

package
v0.1.0-test Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfigSet = Config{
	BroadcastChanSize:        100,
	ConfirmPollSecs:          5,
	SendRetryDelay:           3 * time.Second,
	MaxSendRetryAttempts:     5,
	TxExpirationMins:         5,
	StickyNodeContextEnabled: true,
}

Functions

This section is empty.

Types

type AccountStore

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

func NewAccountStore

func NewAccountStore() *AccountStore

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
	ConfirmPollSecs          uint          // Interval to poll for transaction confirmations
	SendRetryDelay           time.Duration // Delay between send retry attempts
	MaxSendRetryAttempts     uint          // Max retries before giving up broadcasting
	TxExpirationMins         uint          // Time (in minutes) after which an unconfirmed transaction is considered expired
	StickyNodeContextEnabled bool          // Whether to use sticky context (single node per lifecycle)
}

type FinalizedTx

type FinalizedTx struct {
	ReceivedMessage tracetracking.ReceivedMessage
	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
}

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
	Expiration      time.Time                     // expiration timestamp based on TTL
	ReceivedMessage tracetracking.ReceivedMessage // received message
}

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() tracetracking.SignedAPIClient
	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 {
	Logger   logger.Logger
	Keystore loop.Keystore
	Config   Config

	Client        tracetracking.SignedAPIClient
	BroadcastChan chan *Tx
	AccountStore  *AccountStore
	Starter       commonutils.StartStopOnce
	Done          sync.WaitGroup
	Stop          chan struct{}
}

func New

func New(lgr logger.Logger, keystore loop.Keystore, client tracetracking.SignedAPIClient, config Config) *Txm

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() tracetracking.SignedAPIClient

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