dao

package
v0.0.0-...-a287f25 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectPostgres

func ConnectPostgres(url string) error

func IsRecordNotFound

func IsRecordNotFound(err error) bool

Types

type DAO

type DAO interface {
	PerpetualDAO
	OrderDAO
	MatchTransactionDAO
	LaunchTransactionDAO
	NonceDAO
	KVStoreDAO
	ForUpdate() // mark "ROW SHARE"
	Transaction(ctx context.Context, isReadOnly bool, body func(DAO) error) (err error)
	RepeatableRead(ctx context.Context, isReadOnly bool, body func(DAO) error) (err error)
}

func New

func New() DAO

func NewFromGormDB

func NewFromGormDB(db *gorm.DB) DAO

type KVStoreDAO

type KVStoreDAO interface {
	Get(key, category string) (*model.KVStore, error)
	Put(value *model.KVStore) error
	Del(key string) error
	List(category ...string) ([]*model.KVStore, error)
}

func NewKVStoreDAO

func NewKVStoreDAO(db *gorm.DB) KVStoreDAO

type LaunchTransactionDAO

type LaunchTransactionDAO interface {
	FirstTx(status ...model.LaunchTransactionStatus) (*model.LaunchTransaction, error)
	FirstTxByUser(addr string, status ...model.LaunchTransactionStatus) (*model.LaunchTransaction, error)
	GetTxsByUser(addr string, blockNumber *uint64, status ...model.LaunchTransactionStatus) ([]*model.LaunchTransaction, error)
	GetTxByID(txID string) (*model.LaunchTransaction, error)
	GetTxByHash(txHash string) (*model.LaunchTransaction, error)
	GetTxsByNonce(user string, nonce *uint64, status ...model.LaunchTransactionStatus) ([]*model.LaunchTransaction, error)
	GetTxsByTime(unmatureTime time.Time, status ...model.LaunchTransactionStatus) ([]*model.LaunchTransaction, error)
	GetUsersWithStatus(status ...model.LaunchTransactionStatus) ([]string, error)

	CreateTx(tx *model.LaunchTransaction) error
	UpdateTx(tx *model.LaunchTransaction) error
}

func NewLaunchTransactionDAO

func NewLaunchTransactionDAO(db *gorm.DB) LaunchTransactionDAO

type MatchTransactionDAO

type MatchTransactionDAO interface {
	CreateMatchTransaction(*model.MatchTransaction) error
	QueryMatchTransaction(poolAddress string, perpIndex int64, status []model.TransactionStatus) ([]*model.MatchTransaction, error)
	QueryUnconfirmedTransactions() ([]*model.MatchTransaction, error)
	QueryUnconfirmedTransactionsByContract(poolAddress string, perpIndex int64) (transactions []*model.MatchTransaction, err error)
	GetMatchTransaction(ID string) (*model.MatchTransaction, error)
	UpdateMatchTransaction(transaction *model.MatchTransaction) error
}

type Nonce

type Nonce struct {
	Address    string `gorm:"primary_key"`
	Nonce      *uint64
	UpdateTime time.Time
}

func (Nonce) TableName

func (Nonce) TableName() string

type NonceDAO

type NonceDAO interface {
	GetNextNonce(addr string) (uint64, bool)
	UpdateNonce(addr string, nonce *uint64) error
}

func NewNonceDAO

func NewNonceDAO(db *gorm.DB) NonceDAO

type OrderDAO

type OrderDAO interface {
	CreateOrder(order *model.Order) error
	GetOrder(orderHash string) (*model.Order, error)
	GetPendingOrderUsers(poolAddress string, perpIndex int64, status []model.OrderStatus) ([]string, error)
	QueryOrder(traderAddress string, poolAddress string, perpIndex int64, status []model.OrderStatus, beforeOrderID, afterOrderID int64, limit int) ([]*model.Order, error)
	QueryOrderWithCreateTime(traderAddress string, poolAddress string, perpIndex int64,
		status []model.OrderStatus, beforeOrderID, afterOrderID int64, beginTime, endTime time.Time, limit int) ([]*model.Order, error)
	GetOrderByHashs(hashs []string) ([]*model.Order, error)
	UpdateOrder(order *model.Order) error
	LoadMatchOrders(matchItems []*model.MatchItem) error
}

func NewOrderDAO

func NewOrderDAO(db *gorm.DB) OrderDAO

type PerpetualDAO

type PerpetualDAO interface {
	CreatePerpetual(*model.Perpetual) error
	GetPerpetualSyncedBlockNumber() (int64, error)
	// Query all the perpetuals
	// if isPublished is true, return published perpetuals only otherwise return all the perpetuals
	QueryPerpetuals(publishedOnly bool) ([]*model.Perpetual, error)
	GetPerpetualByPoolAddressAndIndex(address string, index int64, publishedOnly bool) (*model.Perpetual, error)
	UpdatePerpetual(*model.Perpetual) error
}

func NewPerpetualDAO

func NewPerpetualDAO(db *gorm.DB) PerpetualDAO

Jump to

Keyboard shortcuts

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