txm

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: MIT Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MAX_RETRY_ATTEMPTS           = 5
	MAX_BROADCAST_RETRY_DURATION = 30 * time.Second
	BROADCAST_DELAY_DURATION     = 2 * time.Second
	DEFAULT_ENERGY_MULTIPLIER    = 1.5
)
View Source
const DEFAULT_ENERGY_UNIT_PRICE int32 = 210 // as of 2025-02-10

Variables

This section is empty.

Functions

func CalculatePaddedFeeLimit

func CalculatePaddedFeeLimit(feeLimit int32, bumpTimes uint32, multiplier float64) int32

func ParseLatestEnergyPrice

func ParseLatestEnergyPrice(energyPricesStr string) (int32, error)

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

func (*AccountStore) GetTotalInflightCount

func (c *AccountStore) GetTotalInflightCount() int

func (*AccountStore) GetTxStore

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

type TronTx

type TronTx struct {
	FromAddress     address.Address
	ContractAddress address.Address
	Method          string
	Params          []any
	Attempt         uint64
	OutOfTimeErrors uint64
	EnergyBumpTimes uint32
}

type TronTxm

type TronTxm struct {
	Logger                logger.Logger
	Keystore              loop.Keystore
	Config                TronTxmConfig
	EstimateEnergyEnabled bool // TODO: Move this to a NodeState/Config struct when we move to MultiNode

	Client        sdk.FullNodeClient
	BroadcastChan chan *TronTx
	AccountStore  *AccountStore
	Starter       utils.StartStopOnce
	Done          sync.WaitGroup
	Stop          chan struct{}
}

func New

func New(lgr logger.Logger, keystore loop.Keystore, client sdk.FullNodeClient, config TronTxmConfig) *TronTxm

func (*TronTxm) Close

func (t *TronTxm) Close() error

func (*TronTxm) Enqueue

func (t *TronTxm) Enqueue(request TronTxmRequest) error

Enqueues a transaction for broadcasting. Each item in the params array should be a map with a single key-value pair, where the key is the ABI type.

func (*TronTxm) GetClient

func (t *TronTxm) GetClient() sdk.FullNodeClient

func (*TronTxm) HealthReport

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

func (*TronTxm) InflightCount

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

func (*TronTxm) Name

func (t *TronTxm) Name() string

func (*TronTxm) Ready

func (t *TronTxm) Ready() error

func (*TronTxm) SignAndBroadcast

func (t *TronTxm) SignAndBroadcast(ctx context.Context, fromAddress address.Address, coreTx *common.Transaction) (*fullnode.BroadcastResponse, error)

func (*TronTxm) Start

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

func (*TronTxm) TriggerSmartContract

func (t *TronTxm) TriggerSmartContract(ctx context.Context, tx *TronTx) (*fullnode.TriggerSmartContractResponse, error)

type TronTxmConfig

type TronTxmConfig struct {
	BroadcastChanSize uint
	ConfirmPollSecs   uint
	EnergyMultiplier  float64
}

type TronTxmRequest

type TronTxmRequest struct {
	FromAddress     address.Address
	ContractAddress address.Address
	Method          string
	Params          []any
}

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(hash string, expirationMs int64, tx *TronTx) error

func (*TxStore) Confirm

func (s *TxStore) Confirm(hash string) error

func (*TxStore) GetUnconfirmed

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

func (*TxStore) InflightCount

func (s *TxStore) InflightCount() int

type UnconfirmedTx

type UnconfirmedTx struct {
	Hash         string
	ExpirationMs int64
	Tx           *TronTx
}

Jump to

Keyboard shortcuts

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