tx

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusFailed = iota
	StatusPending
	StatusExecuted
	StatusPacked
	StatusCommitted
	StatusVerified
)
View Source
const (
	PoolTxTableName = `pool_tx`
)
View Source
const TxDetailTableName = `tx_detail`
View Source
const (
	TxTableName = `tx`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GetTxOptionFunc added in v0.0.5

type GetTxOptionFunc func(*getTxOption)

func GetTxWithDeleted added in v0.0.5

func GetTxWithDeleted() GetTxOptionFunc

func GetTxWithFromHash added in v0.0.5

func GetTxWithFromHash(hash string) GetTxOptionFunc

func GetTxWithStatuses added in v0.0.5

func GetTxWithStatuses(statuses []int64) GetTxOptionFunc

func GetTxWithTypes added in v0.0.5

func GetTxWithTypes(txTypes []int64) GetTxOptionFunc

type PoolTx

type PoolTx struct {
	Tx
}

func (*PoolTx) TableName

func (*PoolTx) TableName() string

type Tx

type Tx struct {
	gorm.Model

	// Assigned when created in the tx pool.
	TxHash       string `gorm:"uniqueIndex"`
	TxType       int64
	TxInfo       string
	AccountIndex int64
	Nonce        int64
	ExpiredAt    int64

	// Assigned after executed.
	GasFee        string
	GasFeeAssetId int64
	NftIndex      int64
	CollectionId  int64
	AssetId       int64
	TxAmount      string
	Memo          string
	ExtraInfo     string
	NativeAddress string      // a. Priority tx, assigned when created b. Other tx, assigned after executed.
	TxDetails     []*TxDetail `gorm:"foreignKey:TxId"`

	TxIndex     int64
	BlockHeight int64 `gorm:"index"`
	BlockId     int64 `gorm:"index"`
	TxStatus    int   `gorm:"index"`
}

func (*Tx) TableName

func (*Tx) TableName() string

type TxDetail

type TxDetail struct {
	gorm.Model
	TxId            int64 `gorm:"index"`
	AssetId         int64
	AssetType       int64
	AccountIndex    int64 `gorm:"index"`
	AccountName     string
	Balance         string
	BalanceDelta    string
	Order           int64
	AccountOrder    int64
	Nonce           int64
	CollectionNonce int64
	IsGas           bool `gorm:"default:false"`
}

func (*TxDetail) TableName

func (*TxDetail) TableName() string

type TxDetailModel

type TxDetailModel interface {
	CreateTxDetailTable() error
	DropTxDetailTable() error
}

func NewTxDetailModel

func NewTxDetailModel(db *gorm.DB) TxDetailModel

type TxModel

type TxModel interface {
	CreateTxTable() error
	DropTxTable() error
	GetTxsTotalCount(options ...GetTxOptionFunc) (count int64, err error)
	GetTxs(limit int64, offset int64, options ...GetTxOptionFunc) (txList []*Tx, err error)
	GetTxsByAccountIndex(accountIndex int64, limit int64, offset int64, options ...GetTxOptionFunc) (txList []*Tx, err error)
	GetTxsCountByAccountIndex(accountIndex int64, options ...GetTxOptionFunc) (count int64, err error)
	GetTxByHash(txHash string) (tx *Tx, err error)
	GetTxsTotalCountBetween(from, to time.Time) (count int64, err error)
	GetDistinctAccountsCountBetween(from, to time.Time) (count int64, err error)
	UpdateTxsStatusInTransact(tx *gorm.DB, blockTxStatus map[int64]int) error
}

func NewTxModel

func NewTxModel(db *gorm.DB) TxModel

type TxPoolModel

type TxPoolModel interface {
	CreatePoolTxTable() error
	DropPoolTxTable() error
	GetTxs(limit int64, offset int64, options ...GetTxOptionFunc) (txs []*Tx, err error)
	GetTxsTotalCount(options ...GetTxOptionFunc) (count int64, err error)
	GetTxByTxHash(hash string) (txs *Tx, err error)
	GetTxsByStatus(status int) (txs []*Tx, err error)
	CreateTxs(txs []*Tx) error
	GetPendingTxsByAccountIndex(accountIndex int64, options ...GetTxOptionFunc) (txs []*Tx, err error)
	GetMaxNonceByAccountIndex(accountIndex int64) (nonce int64, err error)
	CreateTxsInTransact(tx *gorm.DB, txs []*Tx) error
	UpdateTxsInTransact(tx *gorm.DB, txs []*Tx) error
	DeleteTxsInTransact(tx *gorm.DB, txs []*Tx) error
	GetLatestTx(txTypes []int64, statuses []int) (tx *Tx, err error)
}

func NewTxPoolModel

func NewTxPoolModel(db *gorm.DB) TxPoolModel

Jump to

Keyboard shortcuts

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