dao

package
v0.0.0-...-491e088 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TrendUpdateType = "last_trend__proof_time"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	ID          int    `gorm:"column:id;primary_key"`
	BlockNumber int64  `gorm:"column:block_number;type:bigint"`
	BlockHash   string `gorm:"column:block_hash;type:varchar(82)"`
	ParentHash  string `gorm:"column:parent_hash;type:varchar(82)"`
	CreateTime  int64  `gorm:"column:create_time"`
	Fork        bool   `gorm:"column:fork;"`
}

func (*Block) ConvertDown

func (b *Block) ConvertDown(src *types.Block) error

convert types/block to dao/block

func (*Block) ConvertUp

func (b *Block) ConvertUp(dst *types.Block) error

convert dao/block to types/block

type CancelEvent

type CancelEvent struct {
	ID              int    `gorm:"column:id;primary_key;"`
	Protocol        string `gorm:"column:contract_address;type:varchar(42)"`
	DelegateAddress string `gorm:"column:delegate_address;type:varchar(42)"`
	OrderHash       string `gorm:"column:order_hash;type:varchar(82)"`
	TxHash          string `gorm:"column:tx_hash;type:varchar(82)"`
	BlockNumber     int64  `gorm:"column:block_number"`
	CreateTime      int64  `gorm:"column:create_time"`
	AmountCancelled string `gorm:"column:amount_cancelled;type:varchar(40)"`
	LogIndex        int64  `gorm:"column:log_index"`
	Fork            bool   `gorm:"column:fork"`
}

func (*CancelEvent) ConvertDown

func (e *CancelEvent) ConvertDown(src *types.OrderCancelledEvent) error

convert chainClient/orderCancelledEvent to dao/CancelEvent

func (*CancelEvent) ConvertUp

func (e *CancelEvent) ConvertUp(dst *types.OrderCancelledEvent) error

convert dao/cancelEvent to types/cancelEvent

type CheckPoint

type CheckPoint struct {
	ID           int    `gorm:"column:id;primary_key;"`
	BusinessType string `gorm:"column:business_type;type:varchar(42);unique_index"`
	CheckPoint   int64  `gorm:"column:check_point;type:bigint"`
	CreateTime   int64  `gorm:"column:create_time;type:bigint"`
	ModifyTime   int64  `gorm:"column:modify_time;type:bigint"`
}

common check point table

type CutOffEvent

type CutOffEvent struct {
	ID              int    `gorm:"column:id;primary_key;"`
	Protocol        string `gorm:"column:contract_address;type:varchar(42)"`
	DelegateAddress string `gorm:"column:delegate_address;type:varchar(42)"`
	Owner           string `gorm:"column:owner;type:varchar(42)"`
	TxHash          string `gorm:"column:tx_hash;type:varchar(82)"`
	OrderHashList   string `gorm:"column:order_hash_list;type:text"`
	BlockNumber     int64  `gorm:"column:block_number"`
	Cutoff          int64  `gorm:"column:cutoff"`
	LogIndex        int64  `gorm:"column:log_index"`
	Fork            bool   `gorm:"column:fork"`
	CreateTime      int64  `gorm:"column:create_time"`
}

todo(fuk): rename table

func (*CutOffEvent) ConvertDown

func (e *CutOffEvent) ConvertDown(src *types.CutoffEvent) error

convert types/cutoffEvent to dao/CancelEvent

func (*CutOffEvent) ConvertUp

func (e *CutOffEvent) ConvertUp(dst *types.CutoffEvent) error

convert dao/cutoffEvent to types/cutoffEvent

type CutOffPairEvent

type CutOffPairEvent struct {
	ID              int    `gorm:"column:id;primary_key;"`
	Protocol        string `gorm:"column:contract_address;type:varchar(42)"`
	DelegateAddress string `gorm:"column:delegate_address;type:varchar(42)"`
	Owner           string `gorm:"column:owner;type:varchar(42)"`
	Token1          string `gorm:"column:token1;type:varchar(42)"`
	Token2          string `gorm:"column:token2;type:varchar(42)"`
	TxHash          string `gorm:"column:tx_hash;type:varchar(82)"`
	OrderHashList   string `gorm:"column:order_hash_list;type:text"`
	BlockNumber     int64  `gorm:"column:block_number"`
	LogIndex        int64  `gorm:"column:log_index"`
	Cutoff          int64  `gorm:"column:cutoff"`
	CreateTime      int64  `gorm:"column:create_time"`
	Fork            bool   `gorm:"column:fork"`
}

func (*CutOffPairEvent) ConvertDown

func (e *CutOffPairEvent) ConvertDown(src *types.CutoffPairEvent) error

convert types/cutoffPairEvent to dao/cutoffPairEvent

func (*CutOffPairEvent) ConvertUp

func (e *CutOffPairEvent) ConvertUp(dst *types.CutoffPairEvent) error

convert dao/cutoffPairEvent to types/cutoffPairEvent

type FillEvent

type FillEvent struct {
	ID              int    `gorm:"column:id;primary_key;" json:"id"`
	Protocol        string `gorm:"column:contract_address;type:varchar(42)" json:"protocol"`
	DelegateAddress string `gorm:"column:delegate_address;type:varchar(42)" json:"delegateAddress"`
	Owner           string `gorm:"column:owner;type:varchar(42)" json:"owner"`
	RingIndex       int64  `gorm:"column:ring_index;" json:"ringIndex"`
	BlockNumber     int64  `gorm:"column:block_number" json:"blockNumber"`
	CreateTime      int64  `gorm:"column:create_time" json:"createTime"`
	RingHash        string `gorm:"column:ring_hash;varchar(82)" json:"ringHash"`
	FillIndex       int64  `gorm:"column:fill_index" json:"fillIndex"`
	TxHash          string `gorm:"column:tx_hash;type:varchar(82)" json:"txHash"`
	PreOrderHash    string `gorm:"column:pre_order_hash;varchar(82)" json:"preOrderHash"`
	NextOrderHash   string `gorm:"column:next_order_hash;varchar(82)" json:"nextOrderHash"`
	OrderHash       string `gorm:"column:order_hash;type:varchar(82)" json:"orderHash"`
	AmountS         string `gorm:"column:amount_s;type:varchar(40)" json:"amountS"`
	AmountB         string `gorm:"column:amount_b;type:varchar(40)" json:"amountB"`
	TokenS          string `gorm:"column:token_s;type:varchar(42)" json:"tokenS"`
	TokenB          string `gorm:"column:token_b;type:varchar(42)" json:"tokenB"`
	LrcReward       string `gorm:"column:lrc_reward;type:varchar(40)" json:"lrcReward"`
	LrcFee          string `gorm:"column:lrc_fee;type:varchar(40)" json:"lrcFee"`
	SplitS          string `gorm:"column:split_s;type:varchar(40)" json:"splitS"`
	SplitB          string `gorm:"column:split_b;type:varchar(40)" json:"splitB"`
	Market          string `gorm:"column:market;type:varchar(42)" json:"market"`
	LogIndex        int64  `gorm:"column:log_index"`
	Fork            bool   `gorm:"column:fork"`
	Side            string `gorm:"column:side" json:"side"`
	OrderType       string `gorm:"column:order_type" json:"orderType"`
}

func (*FillEvent) ConvertDown

func (f *FillEvent) ConvertDown(src *types.OrderFilledEvent) error

convert chainclient/orderFilledEvent to dao/fill

func (*FillEvent) ConvertUp

func (f *FillEvent) ConvertUp(dst *types.OrderFilledEvent) error

convert dao/fill to types/fill

type FilledOrder

type FilledOrder struct {
	ID               int    `gorm:"column:id;primary_key;"`
	RingHash         string `gorm:"column:ringhash;type:varchar(82)"`
	OrderHash        string `gorm:"column:orderhash;type:varchar(82)"`
	FeeSelection     uint8  `gorm:"column:fee_selection" json:"feeSelection"`
	RateAmountS      string `gorm:"column:rate_amount_s;type:text" json:"rateAmountS"`
	AvailableAmountS string `gorm:"column:available_amount_s;type:text"json:"availableAmountS"`
	AvailableAmountB string `gorm:"column:available_amount_b;type:text"`
	FillAmountS      string `gorm:"column:fill_amount_s;type:text" json:"fillAmountS"`
	FillAmountB      string `gorm:"column:fill_amount_b;type:text" json:"fillAmountB"`
	LrcReward        string `gorm:"column:lrc_reward;type:text" json:"lrcReward"`
	LrcFee           string `gorm:"column:lrc_fee;type:text" json:"lrcFee"`
	FeeS             string `gorm:"column:fee_s;type:text" json:"feeS"`
	LegalFee         string `gorm:"column:legal_fee;type:text" json:"legalFee"`
	SPrice           string `gorm:"column:s_price;type:text" json:"sPrice"`
	BPrice           string `gorm:"column:b_price;type:text" json:"sPrice"`
}

func (*FilledOrder) ConvertDown

func (daoFilledOrder *FilledOrder) ConvertDown(filledOrder *types.FilledOrder, ringhash common.Hash) error

func (*FilledOrder) ConvertUp

func (daoFilledOrder *FilledOrder) ConvertUp(filledOrder *types.FilledOrder, rds RdsService) error

type Order

type Order struct {
	ID                    int     `gorm:"column:id;primary_key;"`
	Protocol              string  `gorm:"column:protocol;type:varchar(42)"`
	DelegateAddress       string  `gorm:"column:delegate_address;type:varchar(42)"`
	Owner                 string  `gorm:"column:owner;type:varchar(42)"`
	AuthAddress           string  `gorm:"column:auth_address;type:varchar(42)"`
	PrivateKey            string  `gorm:"column:priv_key;type:varchar(128)"`
	WalletAddress         string  `gorm:"column:wallet_address;type:varchar(42)"`
	OrderHash             string  `gorm:"column:order_hash;type:varchar(82)"`
	TokenS                string  `gorm:"column:token_s;type:varchar(42)"`
	TokenB                string  `gorm:"column:token_b;type:varchar(42)"`
	AmountS               string  `gorm:"column:amount_s;type:varchar(40)"`
	AmountB               string  `gorm:"column:amount_b;type:varchar(40)"`
	CreateTime            int64   `gorm:"column:create_time;type:bigint"`
	ValidSince            int64   `gorm:"column:valid_since;type:bigint"`
	ValidUntil            int64   `gorm:"column:valid_until;type:bigint"`
	LrcFee                string  `gorm:"column:lrc_fee;type:varchar(40)"`
	BuyNoMoreThanAmountB  bool    `gorm:"column:buy_nomore_than_amountb"`
	MarginSplitPercentage uint8   `gorm:"column:margin_split_percentage;type:tinyint(4)"`
	V                     uint8   `gorm:"column:v;type:tinyint(4)"`
	R                     string  `gorm:"column:r;type:varchar(66)"`
	S                     string  `gorm:"column:s;type:varchar(66)"`
	PowNonce              uint64  `gorm:"column:pow_nonce;type:bigint"`
	Price                 float64 `gorm:"column:price;type:decimal(28,16);"`
	UpdatedBlock          int64   `gorm:"column:updated_block;type:bigint"`
	DealtAmountS          string  `gorm:"column:dealt_amount_s;type:varchar(40)"`
	DealtAmountB          string  `gorm:"column:dealt_amount_b;type:varchar(40)"`
	CancelledAmountS      string  `gorm:"column:cancelled_amount_s;type:varchar(40)"`
	CancelledAmountB      string  `gorm:"column:cancelled_amount_b;type:varchar(40)"`
	SplitAmountS          string  `gorm:"column:split_amount_s;type:varchar(40)"`
	SplitAmountB          string  `gorm:"column:split_amount_b;type:varchar(40)"`
	Status                uint8   `gorm:"column:status;type:tinyint(4)"`
	MinerBlockMark        int64   `gorm:"column:miner_block_mark;type:bigint"`
	BroadcastTime         int     `gorm:"column:broadcast_time;type:bigint"`
	Market                string  `gorm:"column:market;type:varchar(40)"`
	Side                  string  `gorm:"column:side;type:varchar(40)`
	OrderType             string  `gorm:"column:order_type;type:varchar(40)`
}

func (*Order) ConvertDown

func (o *Order) ConvertDown(state *types.OrderState) error

convert types/orderState to dao/order

func (*Order) ConvertUp

func (o *Order) ConvertUp(state *types.OrderState) error

convert dao/order to types/orderState

type PageResult

type PageResult struct {
	Data      []interface{} `json:"data"`
	PageIndex int           `json:"pageIndex"`
	PageSize  int           `json:"pageSize"`
	Total     int           `json:"total"`
}

type RdsService

type RdsService interface {
	// create tables
	Prepare()

	// base functions
	Add(item interface{}) error
	Del(item interface{}) error
	First(item interface{}) error
	Last(item interface{}) error
	Save(item interface{}) error
	FindAll(item interface{}) error

	// ring mined table
	FindRingMined(txhash string) (*RingMinedEvent, error)
	RollBackRingMined(from, to int64) error

	// order table
	GetOrderByHash(orderhash common.Hash) (*Order, error)
	GetOrdersByHash(orderhashs []string) (map[string]Order, error)
	MarkMinerOrders(filterOrderhashs []string, blockNumber int64) error
	GetOrdersForMiner(protocol, tokenS, tokenB string, length int, filterStatus []types.OrderStatus, reservedTime, startBlockNumber, endBlockNumber int64) ([]*Order, error)
	GetCutoffOrders(owner common.Address, cutoffTime *big.Int) ([]Order, error)
	GetCutoffPairOrders(owner, token1, token2 common.Address, cutoffTime *big.Int) ([]Order, error)
	SetCutOffOrders(orderHashList []common.Hash, blockNumber *big.Int) error
	GetOrderBook(protocol, tokenS, tokenB common.Address, length int) ([]Order, error)
	OrderPageQuery(query map[string]interface{}, statusList []int, pageIndex, pageSize int) (PageResult, error)
	UpdateBroadcastTimeByHash(hash string, bt int) error
	UpdateOrderWhileRollbackCutoff(orderhash common.Hash, status types.OrderStatus, blockNumber *big.Int) error
	UpdateOrderWhileFill(hash common.Hash, status types.OrderStatus, dealtAmountS, dealtAmountB, splitAmountS, splitAmountB, blockNumber *big.Int) error
	UpdateOrderWhileCancel(hash common.Hash, status types.OrderStatus, cancelledAmountS, cancelledAmountB, blockNumber *big.Int) error
	GetFrozenAmount(owner common.Address, token common.Address, statusSet []types.OrderStatus, delegateAddress common.Address) ([]Order, error)
	GetFrozenLrcFee(owner common.Address, statusSet []types.OrderStatus) ([]Order, error)

	// block table
	FindBlockByHash(blockhash common.Hash) (*Block, error)
	FindLatestBlock() (*Block, error)
	SetForkBlock(from, to int64) error
	SaveBlock(latest *Block) error

	// fill event table
	FindFillEvent(txhash string, FillIndex int64) (*FillEvent, error)
	QueryRecentFills(mkt, owner string, start int64, end int64) (fills []FillEvent, err error)
	GetFillForkEvents(from, to int64) ([]FillEvent, error)
	RollBackFill(from, to int64) error
	FillsPageQuery(query map[string]interface{}, pageIndex, pageSize int) (res PageResult, err error)
	GetLatestFills(query map[string]interface{}, limit int) (res []FillEvent, err error)
	FindFillsByRingHash(ringHash common.Hash) ([]FillEvent, error)

	// cancel event table
	GetCancelEvent(txhash common.Hash) (CancelEvent, error)
	RollBackCancel(from, to int64) error
	GetCancelForkEvents(from, to int64) ([]CancelEvent, error)

	// cutoff event table
	GetCutoffEvent(txhash common.Hash) (CutOffEvent, error)
	GetCutoffForkEvents(from, to int64) ([]CutOffEvent, error)
	RollBackCutoff(from, to int64) error

	// cutoffpair event table
	GetCutoffPairEvent(txhash common.Hash) (CutOffPairEvent, error)
	GetCutoffPairForkEvents(from, to int64) ([]CutOffPairEvent, error)
	RollBackCutoffPair(from, to int64) error

	// trend table
	TrendQueryLatest(query Trend, pageIndex, pageSize int) (trends []Trend, err error)
	TrendQueryByTime(intervals, market string, start, end int64) (trends []Trend, err error)
	TrendQueryByInterval(intervals, market string, start, end int64) (trends []Trend, err error)
	TrendQueryForProof(mkt string, interval string, start int64) (trends []Trend, err error)

	// white list
	GetWhiteList() ([]WhiteList, error)
	FindWhiteListUserByAddress(address common.Address) (*WhiteList, error)

	UpdateRingSubmitInfoResult(submitResult *types.RingSubmitResultEvent) error
	GetRingForSubmitByHash(ringhash common.Hash) (RingSubmitInfo, error)
	GetRingHashesByTxHash(txHash common.Hash) ([]*RingSubmitInfo, error)
	RingMinedPageQuery(query map[string]interface{}, pageIndex, pageSize int) (res PageResult, err error)
	GetRingminedMethods(lastId int, limit int) ([]RingMinedEvent, error)
	GetFilledOrderByRinghash(ringhash common.Hash) ([]*FilledOrder, error)

	// transactions
	GetTransactionById(id int) (Transaction, error)

	// transactionEntity
	FindPendingTxEntity(hash string) (TransactionEntity, error)
	FindTxEntity(txhash string, logIndex int64) (TransactionEntity, error)
	GetTxEntity(hashlist []string) ([]TransactionEntity, error)
	GetPendingTxEntity(from string, nonce int64) ([]TransactionEntity, error)
	SetPendingTxEntityFailed(hashlist []string) error
	DelPendingTxEntity(hash string) error
	RollBackTxEntity(from, to int64) error

	// transactionView
	DelPendingTxView(hash string) error
	SetPendingTxViewFailed(hashlist []string) error
	GetTxViewByOwnerAndHashs(owner string, hashs []string) ([]TransactionView, error)
	GetPendingTxViewByOwner(owner string) ([]TransactionView, error)
	GetTxViewCountByOwner(owner string, symbol string, status types.TxStatus, typ txtyp.TxType) (int, error)
	GetTxViewByOwner(owner string, symbol string, status types.TxStatus, typ txtyp.TxType, limit, offset int) ([]TransactionView, error)
	RollBackTxView(from, to int64) error

	// checkpoint
	QueryCheckPointByType(businessType string) (point CheckPoint, err error)
}

type RdsServiceImpl

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

func NewRdsService

func NewRdsService(options config.MysqlOptions) *RdsServiceImpl

func (*RdsServiceImpl) Add

func (s *RdsServiceImpl) Add(item interface{}) error

add single item

func (*RdsServiceImpl) Del

func (s *RdsServiceImpl) Del(item interface{}) error

del single item

func (*RdsServiceImpl) DelPendingTxEntity

func (s *RdsServiceImpl) DelPendingTxEntity(hash string) error

根据hash&status删除pending tx

func (*RdsServiceImpl) DelPendingTxView

func (s *RdsServiceImpl) DelPendingTxView(hash string) error

根据hash删除pending tx

func (*RdsServiceImpl) FillsPageQuery

func (s *RdsServiceImpl) FillsPageQuery(query map[string]interface{}, pageIndex, pageSize int) (res PageResult, err error)

func (*RdsServiceImpl) FindAll

func (s *RdsServiceImpl) FindAll(item interface{}) error

find all items in table where primary key > 0

func (*RdsServiceImpl) FindBlockByHash

func (s *RdsServiceImpl) FindBlockByHash(blockhash common.Hash) (*Block, error)

func (*RdsServiceImpl) FindFillEvent

func (s *RdsServiceImpl) FindFillEvent(txhash string, FillIndex int64) (*FillEvent, error)

func (*RdsServiceImpl) FindFillsByRingHash

func (s *RdsServiceImpl) FindFillsByRingHash(ringHash common.Hash) ([]FillEvent, error)

func (*RdsServiceImpl) FindLatestBlock

func (s *RdsServiceImpl) FindLatestBlock() (*Block, error)

func (*RdsServiceImpl) FindPendingTxEntity

func (s *RdsServiceImpl) FindPendingTxEntity(hash string) (TransactionEntity, error)

根据hash查询pending tx

func (*RdsServiceImpl) FindRingMined

func (s *RdsServiceImpl) FindRingMined(txhash string) (*RingMinedEvent, error)

func (*RdsServiceImpl) FindTxEntity

func (s *RdsServiceImpl) FindTxEntity(txhash string, logIndex int64) (TransactionEntity, error)

根据hash&logIndex查找唯一tx

func (*RdsServiceImpl) FindWhiteListUserByAddress

func (s *RdsServiceImpl) FindWhiteListUserByAddress(address common.Address) (*WhiteList, error)

func (*RdsServiceImpl) First

func (s *RdsServiceImpl) First(item interface{}) error

select first item order by primary key asc

func (*RdsServiceImpl) GetCancelEvent

func (s *RdsServiceImpl) GetCancelEvent(txhash common.Hash) (CancelEvent, error)

func (*RdsServiceImpl) GetCancelForkEvents

func (s *RdsServiceImpl) GetCancelForkEvents(from, to int64) ([]CancelEvent, error)

func (*RdsServiceImpl) GetCutoffEvent

func (s *RdsServiceImpl) GetCutoffEvent(txhash common.Hash) (CutOffEvent, error)

func (*RdsServiceImpl) GetCutoffForkEvents

func (s *RdsServiceImpl) GetCutoffForkEvents(from, to int64) ([]CutOffEvent, error)

func (*RdsServiceImpl) GetCutoffOrders

func (s *RdsServiceImpl) GetCutoffOrders(owner common.Address, cutoffTime *big.Int) ([]Order, error)

func (*RdsServiceImpl) GetCutoffPairEvent

func (s *RdsServiceImpl) GetCutoffPairEvent(txhash common.Hash) (CutOffPairEvent, error)

func (*RdsServiceImpl) GetCutoffPairForkEvents

func (s *RdsServiceImpl) GetCutoffPairForkEvents(from, to int64) ([]CutOffPairEvent, error)

func (*RdsServiceImpl) GetCutoffPairOrders

func (s *RdsServiceImpl) GetCutoffPairOrders(owner, token1, token2 common.Address, cutoffTime *big.Int) ([]Order, error)

func (*RdsServiceImpl) GetFillForkEvents

func (s *RdsServiceImpl) GetFillForkEvents(from, to int64) ([]FillEvent, error)

func (*RdsServiceImpl) GetFilledOrderByRinghash

func (s *RdsServiceImpl) GetFilledOrderByRinghash(ringhash common.Hash) ([]*FilledOrder, error)

func (*RdsServiceImpl) GetFrozenAmount

func (s *RdsServiceImpl) GetFrozenAmount(owner common.Address, token common.Address, statusSet []types.OrderStatus, delegateAddress common.Address) ([]Order, error)

func (*RdsServiceImpl) GetFrozenLrcFee

func (s *RdsServiceImpl) GetFrozenLrcFee(owner common.Address, statusSet []types.OrderStatus) ([]Order, error)

func (*RdsServiceImpl) GetLatestFills

func (s *RdsServiceImpl) GetLatestFills(query map[string]interface{}, limit int) (res []FillEvent, err error)

func (*RdsServiceImpl) GetOrderBook

func (s *RdsServiceImpl) GetOrderBook(delegate, tokenS, tokenB common.Address, length int) ([]Order, error)

func (*RdsServiceImpl) GetOrderByHash

func (s *RdsServiceImpl) GetOrderByHash(orderhash common.Hash) (*Order, error)

func (*RdsServiceImpl) GetOrdersByHash

func (s *RdsServiceImpl) GetOrdersByHash(orderhashs []string) (map[string]Order, error)

func (*RdsServiceImpl) GetOrdersForMiner

func (s *RdsServiceImpl) GetOrdersForMiner(protocol, tokenS, tokenB string, length int, filterStatus []types.OrderStatus, reservedTime, startBlockNumber, endBlockNumber int64) ([]*Order, error)

func (*RdsServiceImpl) GetPendingTxEntity

func (s *RdsServiceImpl) GetPendingTxEntity(from string, nonce int64) ([]TransactionEntity, error)

根据交易发起者from地址及nonce获取pending tx

func (*RdsServiceImpl) GetPendingTxViewByOwner

func (s *RdsServiceImpl) GetPendingTxViewByOwner(owner string) ([]TransactionView, error)

func (*RdsServiceImpl) GetRingForSubmitByHash

func (s *RdsServiceImpl) GetRingForSubmitByHash(ringhash common.Hash) (ringForSubmit RingSubmitInfo, err error)

func (*RdsServiceImpl) GetRingHashesByTxHash

func (s *RdsServiceImpl) GetRingHashesByTxHash(txHash common.Hash) ([]*RingSubmitInfo, error)

func (*RdsServiceImpl) GetRingminedMethods

func (s *RdsServiceImpl) GetRingminedMethods(lastId int, limit int) ([]RingMinedEvent, error)

func (*RdsServiceImpl) GetTransactionById

func (s *RdsServiceImpl) GetTransactionById(id int) (Transaction, error)

func (*RdsServiceImpl) GetTxEntity

func (s *RdsServiceImpl) GetTxEntity(hashlist []string) ([]TransactionEntity, error)

func (*RdsServiceImpl) GetTxViewByOwner

func (s *RdsServiceImpl) GetTxViewByOwner(owner string, symbol string, status types.TxStatus, typ txtyp.TxType, limit, offset int) ([]TransactionView, error)

func (*RdsServiceImpl) GetTxViewByOwnerAndHashs

func (s *RdsServiceImpl) GetTxViewByOwnerAndHashs(owner string, hashs []string) ([]TransactionView, error)

////////// read related

func (*RdsServiceImpl) GetTxViewCountByOwner

func (s *RdsServiceImpl) GetTxViewCountByOwner(owner string, symbol string, status types.TxStatus, typ txtyp.TxType) (int, error)

func (*RdsServiceImpl) GetWhiteList

func (s *RdsServiceImpl) GetWhiteList() ([]WhiteList, error)

func (*RdsServiceImpl) Last

func (s *RdsServiceImpl) Last(item interface{}) error

select the last item order by primary key asc

func (*RdsServiceImpl) MarkMinerOrders

func (s *RdsServiceImpl) MarkMinerOrders(filterOrderhashs []string, blockNumber int64) error

func (*RdsServiceImpl) OrderPageQuery

func (s *RdsServiceImpl) OrderPageQuery(query map[string]interface{}, statusList []int, pageIndex, pageSize int) (PageResult, error)

func (*RdsServiceImpl) Prepare

func (s *RdsServiceImpl) Prepare()

func (*RdsServiceImpl) QueryCheckPointByType

func (s *RdsServiceImpl) QueryCheckPointByType(businessType string) (point CheckPoint, err error)

func (*RdsServiceImpl) QueryRecentFills

func (s *RdsServiceImpl) QueryRecentFills(market, owner string, start int64, end int64) (fills []FillEvent, err error)

func (*RdsServiceImpl) RingMinedPageQuery

func (s *RdsServiceImpl) RingMinedPageQuery(query map[string]interface{}, pageIndex, pageSize int) (res PageResult, err error)

func (*RdsServiceImpl) RollBackCancel

func (s *RdsServiceImpl) RollBackCancel(from, to int64) error

func (*RdsServiceImpl) RollBackCutoff

func (s *RdsServiceImpl) RollBackCutoff(from, to int64) error

func (*RdsServiceImpl) RollBackCutoffPair

func (s *RdsServiceImpl) RollBackCutoffPair(from, to int64) error

func (*RdsServiceImpl) RollBackFill

func (s *RdsServiceImpl) RollBackFill(from, to int64) error

func (*RdsServiceImpl) RollBackRingMined

func (s *RdsServiceImpl) RollBackRingMined(from, to int64) error

func (*RdsServiceImpl) RollBackTxEntity

func (s *RdsServiceImpl) RollBackTxEntity(from, to int64) error

func (*RdsServiceImpl) RollBackTxView

func (s *RdsServiceImpl) RollBackTxView(from, to int64) error

func (*RdsServiceImpl) Save

func (s *RdsServiceImpl) Save(item interface{}) error

update single item

func (*RdsServiceImpl) SaveBlock

func (s *RdsServiceImpl) SaveBlock(latest *Block) error

func (*RdsServiceImpl) SetCutOffOrders

func (s *RdsServiceImpl) SetCutOffOrders(orderHashList []common.Hash, blockNumber *big.Int) error

func (*RdsServiceImpl) SetForkBlock

func (s *RdsServiceImpl) SetForkBlock(from, to int64) error

func (*RdsServiceImpl) SetPendingTxEntityFailed

func (s *RdsServiceImpl) SetPendingTxEntityFailed(hashlist []string) error

func (*RdsServiceImpl) SetPendingTxViewFailed

func (s *RdsServiceImpl) SetPendingTxViewFailed(hashlist []string) error

更新交易发起者相同nonce下tx为failed

func (*RdsServiceImpl) TrendQueryByInterval

func (s *RdsServiceImpl) TrendQueryByInterval(intervals, market string, start, end int64) (trends []Trend, err error)

func (*RdsServiceImpl) TrendQueryByTime

func (s *RdsServiceImpl) TrendQueryByTime(intervals, market string, start, end int64) (trends []Trend, err error)

func (*RdsServiceImpl) TrendQueryForProof

func (s *RdsServiceImpl) TrendQueryForProof(mkt, interval string, start int64) (trends []Trend, err error)

func (*RdsServiceImpl) TrendQueryLatest

func (s *RdsServiceImpl) TrendQueryLatest(query Trend, pageIndex, pageSize int) (trends []Trend, err error)

func (*RdsServiceImpl) UpdateBroadcastTimeByHash

func (s *RdsServiceImpl) UpdateBroadcastTimeByHash(hash string, bt int) error

func (*RdsServiceImpl) UpdateOrderWhileCancel

func (s *RdsServiceImpl) UpdateOrderWhileCancel(hash common.Hash, status types.OrderStatus, cancelledAmountS, cancelledAmountB, blockNumber *big.Int) error

func (*RdsServiceImpl) UpdateOrderWhileFill

func (s *RdsServiceImpl) UpdateOrderWhileFill(hash common.Hash, status types.OrderStatus, dealtAmountS, dealtAmountB, splitAmountS, splitAmountB, blockNumber *big.Int) error

func (*RdsServiceImpl) UpdateOrderWhileRollbackCutoff

func (s *RdsServiceImpl) UpdateOrderWhileRollbackCutoff(orderhash common.Hash, status types.OrderStatus, blockNumber *big.Int) error

func (*RdsServiceImpl) UpdateRingSubmitInfoResult

func (s *RdsServiceImpl) UpdateRingSubmitInfoResult(submitResult *types.RingSubmitResultEvent) error

func (*RdsServiceImpl) UpdateRingSubmitInfoSubmitUsedGas

func (s *RdsServiceImpl) UpdateRingSubmitInfoSubmitUsedGas(txHash string, usedGas *big.Int) error

type RingMinedEvent

type RingMinedEvent struct {
	ID                 int    `gorm:"column:id;primary_key" json:"id"`
	Protocol           string `gorm:"column:contract_address;type:varchar(42)" json:"protocol"`
	DelegateAddress    string `gorm:"column:delegate_address;type:varchar(42)" json:"delegateAddress"`
	RingIndex          string `gorm:"column:ring_index;type:varchar(40)" json:"ringIndex"`
	RingHash           string `gorm:"column:ring_hash;type:varchar(82)" json:"ringHash"`
	TxHash             string `gorm:"column:tx_hash;type:varchar(82)" json:"txHash"`
	Miner              string `gorm:"column:miner;type:varchar(42);" json:"miner"`
	FeeRecipient       string `gorm:"column:fee_recipient;type:varchar(42)" json:"feeRecipient"`
	IsRinghashReserved bool   `gorm:"column:is_ring_hash_reserved;" json:"isRinghashReserved"`
	BlockNumber        int64  `gorm:"column:block_number;type:bigint" json:"blockNumber"`
	TotalLrcFee        string `gorm:"column:total_lrc_fee;type:varchar(40)" json:"totalLrcFee"`
	TradeAmount        int    `gorm:"column:trade_amount" json:"tradeAmount"`
	Time               int64  `gorm:"column:time;type:bigint" json:"timestamp"`
	Fork               bool   `gorm:"column:fork"`
	Status             uint8  `gorm:"column:status;type:tinyint(4)"`
	GasLimit           string `gorm:"column:gas_limit;type:varchar(50)"`
	GasUsed            string `gorm:"column:gas_used;type:varchar(50)"`
	GasPrice           string `gorm:"column:gas_price;type:varchar(50)"`
	Err                string `gorm:"column:err;type:text" json:"err"`
}

todo(fuk): delete field isRinghashReserved

func (*RingMinedEvent) ConvertDown

func (r *RingMinedEvent) ConvertDown(event *types.RingMinedEvent) error

func (*RingMinedEvent) ConvertUp

func (r *RingMinedEvent) ConvertUp(event *types.RingMinedEvent) error

func (*RingMinedEvent) FromSubmitRingMethod

func (r *RingMinedEvent) FromSubmitRingMethod(event *types.SubmitRingMethodEvent) error

type RingSubmitInfo

type RingSubmitInfo struct {
	ID               int    `gorm:"column:id;primary_key;"`
	RingHash         string `gorm:"column:ringhash;type:varchar(82)"`
	UniqueId         string `gorm:"column:unique_id;type:varchar(82)"`
	ProtocolAddress  string `gorm:"column:protocol_address;type:varchar(42)"`
	OrdersCount      int64  `gorm:"column:order_count;type:bigint"`
	ProtocolData     string `gorm:"column:protocol_data;type:text"`
	ProtocolGas      string `gorm:"column:protocol_gas;type:varchar(50)"`
	ProtocolGasPrice string `gorm:"column:protocol_gas_price;type:varchar(50)"`
	ProtocolUsedGas  string `gorm:"column:protocol_used_gas;type:varchar(50)"`
	ProtocolTxHash   string `gorm:"column:protocol_tx_hash;type:varchar(82)"`

	Status      int       `gorm:"column:status;type:int"`
	RingIndex   string    `gorm:"column:ring_index;type:varchar(50)"`
	BlockNumber string    `gorm:"column:block_number;type:varchar(50)"`
	Miner       string    `gorm:"column:miner;type:varchar(42)"`
	Err         string    `gorm:"column:err;type:text"`
	CreateTime  time.Time `gorm:"column:create_time;type:TIMESTAMP;default:CURRENT_TIMESTAMP"`
}

func (*RingSubmitInfo) ConvertDown

func (info *RingSubmitInfo) ConvertDown(typesInfo *types.RingSubmitInfo, err error) error

func (*RingSubmitInfo) ConvertUp

func (info *RingSubmitInfo) ConvertUp(typesInfo *types.RingSubmitInfo) error

type Transaction

type Transaction struct {
	ID          int    `gorm:"column:id;primary_key;"`
	Protocol    string `gorm:"column:protocol;type:varchar(42)"`
	Symbol      string `gorm:"column:symbol;type:varchar(20)"`
	Owner       string `gorm:"column:owner;type:varchar(42)"`
	From        string `gorm:"column:tx_from;type:varchar(42)"`
	To          string `gorm:"column:tx_to;type:varchar(42)"`
	RawFrom     string `gorm:"column:raw_from;type:varchar(42)"`
	RawTo       string `gorm:"column:raw_to;type:varchar(42)"`
	TxHash      string `gorm:"column:tx_hash;type:varchar(82)"`
	Content     string `gorm:"column:content;type:text"`
	BlockNumber int64  `gorm:"column:block_number"`
	TxIndex     int64  `gorm:"column:tx_index"`
	LogIndex    int64  `gorm:"column:tx_log_index"`
	Value       string `gorm:"column:amount;type:varchar(64)"`
	Type        uint8  `gorm:"column:tx_type"`
	Status      uint8  `gorm:"column:status"`
	GasLimit    string `gorm:"column:gas_limit;type:varchar(40)"`
	GasUsed     string `gorm:"column:gas_used;type:varchar(40)"`
	GasPrice    string `gorm:"column:gas_price;type:varchar(40)"`
	Nonce       string `gorm:"column:nonce;type:varchar(40)"`
	CreateTime  int64  `gorm:"column:create_time"`
	UpdateTime  int64  `gorm:"column:update_time"`
	Fork        bool   `gorm:"column:fork"`
}

type TransactionEntity

type TransactionEntity struct {
	ID          int    `gorm:"column:id;primary_key;" json:"id"`
	Protocol    string `gorm:"column:protocol;type:varchar(42)" json:"protocol"`
	From        string `gorm:"column:tx_from;type:varchar(42)" json:"from"`
	To          string `gorm:"column:tx_to;type:varchar(42)" json:"to"`
	BlockNumber int64  `gorm:"column:block_number" json:"block_number"`
	TxHash      string `gorm:"column:tx_hash;type:varchar(82)" json:"tx_hash"`
	LogIndex    int64  `gorm:"column:tx_log_index" json:"log_index"`
	Value       string `gorm:"column:amount;type:varchar(64)" json:"value"`
	Content     string `gorm:"column:content;type:text" json:"content"`
	Status      uint8  `gorm:"column:status" json:"status"`
	GasLimit    string `gorm:"column:gas_limit;type:varchar(40)" json:"gas_limit"`
	GasUsed     string `gorm:"column:gas_used;type:varchar(40)" json:"gas_used"`
	GasPrice    string `gorm:"column:gas_price;type:varchar(40)" json:"gas_price"`
	Nonce       int64  `gorm:"column:nonce" json:"nonce"`
	BlockTime   int64  `gorm:"column:block_time" json:"block_time"`
	Fork        bool   `gorm:"column:fork" json:"fork"`
}

txhash&logIndex unique, fork should be marked and never used it again

func (*TransactionEntity) ConvertDown

func (tx *TransactionEntity) ConvertDown(src *txtyp.TransactionEntity) error

convert to txmanager/types/transactionEntity to dao/transactionEntity todo(fuk): judge nil fields

func (*TransactionEntity) ConvertUp

func (tx *TransactionEntity) ConvertUp(dst *txtyp.TransactionEntity) error

convert dao/transactionEntity to txmanager/types/transactionEntity

type TransactionView

type TransactionView struct {
	ID          int    `gorm:"column:id;primary_key;"`
	Symbol      string `gorm:"column:symbol;type:varchar(20)"`
	Owner       string `gorm:"column:owner;type:varchar(42)"`
	TxHash      string `gorm:"column:tx_hash;type:varchar(82)"`
	BlockNumber int64  `gorm:"column:block_number"`
	LogIndex    int64  `gorm:"column:tx_log_index"`
	Amount      string `gorm:"column:amount;type:varchar(40)"`
	Nonce       int64  `gorm:"column:nonce"`
	Type        uint8  `gorm:"column:tx_type"`
	Status      uint8  `gorm:"column:status"`
	CreateTime  int64  `gorm:"column:create_time"`
	UpdateTime  int64  `gorm:"column:update_time"`
	Fork        bool   `gorm:"column:fork"`
}

func (*TransactionView) ConvertDown

func (tx *TransactionView) ConvertDown(src *txtyp.TransactionView) error

convert types/transaction to dao/transaction todo(fuk): judge nil fields

func (*TransactionView) ConvertUp

func (tx *TransactionView) ConvertUp(dst *txtyp.TransactionView) error

convert dao/transaction to types/transaction

type Trend

type Trend struct {
	ID         int     `gorm:"column:id;primary_key;"`
	Market     string  `gorm:"column:market;type:varchar(42);unique_index:market_intervals_start"`
	Intervals  string  `gorm:"column:intervals;type:varchar(42);unique_index:market_intervals_start"`
	Vol        float64 `gorm:"column:vol;type:float"`
	Amount     float64 `gorm:"column:amount;type:float"`
	CreateTime int64   `gorm:"column:create_time;type:bigint"`
	UpdateTime int64   `gorm:"column:update_time;type:bigint"`
	Open       float64 `gorm:"column:open;type:float"`
	Close      float64 `gorm:"column:close;type:float"`
	High       float64 `gorm:"column:high;type:float"`
	Low        float64 `gorm:"column:low;type:float"`
	Start      int64   `gorm:"column:start;type:bigint;unique_index:market_intervals_start"`
	End        int64   `gorm:"column:end;type:bigint"`
}

order amountS 上限1e30

type WhiteList

type WhiteList struct {
	ID         int    `gorm:"column:id;primary_key;"`
	Owner      string `gorm:"column:owner;varchar(42);unique_index"`
	CreateTime int64  `gorm:"column:create_time"`
	IsDeleted  bool   `gorm:"column:is_deleted"`
}

func (*WhiteList) ConvertDown

func (w *WhiteList) ConvertDown(src *types.WhiteListUser) error

func (*WhiteList) ConvertUp

func (w *WhiteList) ConvertUp(dst *types.WhiteListUser) error

Jump to

Keyboard shortcuts

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