txdb

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 16 Imported by: 12

Documentation

Overview

Package txdb provides a database implementation that simplements the submitter db service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllModels

func GetAllModels() (allModels []interface{})

GetAllModels gets all models to migrate see: https://medium.com/@SaifAbid/slice-interfaces-8c78f8b6345d for an explanation of why we can't do this at initialization time

Types

type ETHTX

type ETHTX struct {
	ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true"`
	// UUID is a unique ID for this transaction that will persist across retries.
	UUID string `gorm:"column:uuid;index"`
	// CreatedAt is the time the transaction was created
	CreatedAt time.Time
	// TXHash is the hash of the transaction
	TXHash string `gorm:"column:tx_hash;uniqueIndex;size:256"`
	// From is the sender of the transaction
	From string `gorm:"column:from;index"`
	// ChainID is the chain id the transaction hash will be sent on
	ChainID uint64 `gorm:"column:chain_id;index"`
	// Nonce is the nonce of the raw evm tx
	Nonce uint64 `gorm:"column:nonce;index"`
	// RawTx is the raw serialized transaction
	RawTx []byte `gorm:"column:raw_tx"`
	// Status is the status of the transaction
	Status db.Status `gorm:"column:status;index"`
}

ETHTX contains a raw evm transaction that is unsigned.

type Store

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

Store is the sqlite store. It extends the base store for sqlite specific queries.

func NewTXStore

func NewTXStore(db *gorm.DB, metrics metrics.Handler) *Store

NewTXStore creates a new transaction store.

func (Store) DB

func (s Store) DB() *gorm.DB

DB gets the database.

func (*Store) DBTransaction

func (s *Store) DBTransaction(parentCtx context.Context, f db.TransactionFunc) (err error)

DBTransaction is a function that can be used to execute a transaction on the database.

func (*Store) DeleteTXS added in v0.14.9

func (s *Store) DeleteTXS(ctx context.Context, maxAge time.Duration, matchStatuses ...db.Status) (err error)

DeleteTXS deletes txs that are older than a given duration.

func (*Store) GetAllTXAttemptByStatus

func (s *Store) GetAllTXAttemptByStatus(ctx context.Context, fromAddress common.Address, chainID *big.Int, options ...db.Option) (txs []db.TX, err error)

GetAllTXAttemptByStatus returns all transactions for a given address on a given (or any) chain id that match a given status.

func (*Store) GetChainIDsByStatus added in v0.3.0

func (s *Store) GetChainIDsByStatus(ctx context.Context, fromAddress common.Address, matchStatuses ...db.Status) (chainIDs []*big.Int, err error)

GetChainIDsByStatus returns the distinct chain ids for a given address and status.

func (*Store) GetDistinctChainIDs added in v0.17.5

func (s *Store) GetDistinctChainIDs(ctx context.Context) ([]*big.Int, error)

GetDistinctChainIDs gets a list of all chains that have been used.

func (*Store) GetNonceAttemptsByStatus added in v0.0.100

func (s *Store) GetNonceAttemptsByStatus(ctx context.Context, fromAddress common.Address, chainID *big.Int, nonce uint64, matchStatuses ...db.Status) (txs []db.TX, err error)

GetNonceAttemptsByStatus gets the nonce attempts by status.

func (*Store) GetNonceForChainID

func (s *Store) GetNonceForChainID(ctx context.Context, fromAddress common.Address, chainID *big.Int) (nonce uint64, err error)

GetNonceForChainID gets the nonce for the given chain id.

func (*Store) GetNonceStatus added in v0.0.100

func (s *Store) GetNonceStatus(ctx context.Context, fromAddress common.Address, chainID *big.Int, nonce uint64) (status db.Status, err error)

GetNonceStatus gets the max nonce for the given address and chain id.

func (*Store) GetTXS

func (s *Store) GetTXS(ctx context.Context, fromAddress common.Address, chainID *big.Int, options ...db.Option) (txs []db.TX, err error)

GetTXS returns all transactions for a given address on a given (or any) chain id that match a given status. there is a limit of 50 transactions per chain id. The limit does not make any guarantees about the number of nonces per chain. the submitter will get only the most recent tx submitted for each chain so this can be used for gas pricing.

func (*Store) MarkAllBeforeNonceReplacedOrConfirmed added in v0.6.0

func (s *Store) MarkAllBeforeNonceReplacedOrConfirmed(ctx context.Context, signer common.Address, chainID *big.Int, nonce uint64) error

MarkAllBeforeNonceReplacedOrConfirmed marks all transactions before or at the given nonce as replaced or confirmed.

func (Store) PutTXS

func (s Store) PutTXS(ctx context.Context, txs ...db.TX) error

PutTXS puts a transaction in the database.

Jump to

Keyboard shortcuts

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