Documentation ¶
Index ¶
- func InitSession(session *mgo.Session) (*mgo.Session, error)
- func InitTLSSession() (*mgo.Session, error)
- func NewSecureTLSSession() *mgo.Session
- func NewSession() *mgo.Session
- func NewTLSSession() *mgo.Session
- func OrderDaoDBOption(dbName string) func(dao *OrderDao) error
- func PairDaoDBOption(dbName string) func(dao *PairDao) error
- type AccountDao
- func (dao *AccountDao) Create(a *types.Account) error
- func (dao *AccountDao) Drop()
- func (dao *AccountDao) FindOrCreate(addr string) (*types.Account, error)
- func (dao *AccountDao) GetAll() (res []types.Account, err error)
- func (dao *AccountDao) GetByAddress(owner string) (*types.Account, error)
- func (dao *AccountDao) GetByID(id bson.ObjectId) (*types.Account, error)
- func (dao *AccountDao) GetTokenBalance(owner string, token string) (*types.TokenBalance, error)
- func (dao *AccountDao) GetTokenBalances(owner string) (map[string]*types.TokenBalance, error)
- func (dao *AccountDao) UpdateBalance(owner string, token string, balance int64) error
- func (dao *AccountDao) UpdateTokenBalance(owner, token string, tokenBalance *types.TokenBalance) error
- type Database
- func (d *Database) Aggregate(dbName, collection string, query []bson.M, response interface{}) error
- func (d *Database) Count(dbName, collection string, query interface{}) (n int, err error)
- func (d *Database) Create(dbName, collection string, data ...interface{}) (err error)
- func (d *Database) DropCollection(dbName, collection string) error
- func (d *Database) FindAndModify(dbName, collection string, query interface{}, change mgo.Change, ...) error
- func (d *Database) Get(dbName, collection string, query interface{}, offset, limit int, ...) (err error)
- func (d *Database) GetAndSort(dbName, collection string, query interface{}, sort []string, offset, limit int, ...) (err error)
- func (d *Database) GetByID(dbName, collection string, id bson.ObjectId, response interface{}) (err error)
- func (d *Database) InitDatabase(session *mgo.Session)
- func (d *Database) Query(dbName, collection string, query interface{}, selector interface{}, ...) (err error)
- func (d *Database) Remove(dbName, collection string, query []bson.M) error
- func (d *Database) RemoveAll(dbName, collection string, query interface{}) error
- func (d *Database) Update(dbName, collection string, query interface{}, update interface{}) error
- func (d *Database) UpdateAll(dbName, collection string, query interface{}, update interface{}) error
- func (d *Database) Upsert(dbName, collection string, query interface{}, update interface{}) error
- type OrderDao
- func (dao *OrderDao) Aggregate(q []bson.M) ([]*types.OrderData, error)
- func (dao *OrderDao) Create(o *types.Order) error
- func (dao *OrderDao) Delete(orders ...*types.Order) error
- func (dao *OrderDao) DeleteByHashes(hashes ...string) error
- func (dao *OrderDao) Drop() error
- func (dao *OrderDao) FindAndModify(h string, o *types.Order) (*types.Order, error)
- func (dao *OrderDao) GetByHash(hash string) (*types.Order, error)
- func (dao *OrderDao) GetByHashes(hashes []string) ([]*types.Order, error)
- func (dao *OrderDao) GetByID(id bson.ObjectId) (*types.Order, error)
- func (dao *OrderDao) GetByUserAddress(addr string, limit ...int) ([]*types.Order, error)
- func (dao *OrderDao) GetCurrentByUserAddress(addr string, limit ...int) ([]*types.Order, error)
- func (dao *OrderDao) GetCurrentByUserAddressAndSignerAddress(address string, signer string) ([]*types.Order, error)
- func (dao *OrderDao) GetExpiredOrders() ([]*types.Order, error)
- func (dao *OrderDao) GetHistoryByUserAddress(addr string, limit ...int) ([]*types.Order, error)
- func (dao *OrderDao) GetMatchingBuyOrders(o *types.Order) ([]*types.Order, error)
- func (dao *OrderDao) GetMatchingSellOrders(o *types.Order) ([]*types.Order, error)
- func (dao *OrderDao) GetOrderBook(p *types.Pair) ([]map[string]interface{}, []map[string]interface{}, error)
- func (dao *OrderDao) GetOrderBookPrice(p *types.Pair, pp float64, side string) (int64, string, float64, error)
- func (dao *OrderDao) GetRawOrderBook(p *types.Pair) ([]*types.Order, error)
- func (dao *OrderDao) GetUserLockedBalance(account string, token string) (int64, []*types.Order, error)
- func (dao *OrderDao) Update(id bson.ObjectId, o *types.Order) error
- func (dao *OrderDao) UpdateAllByHash(h string, o *types.Order) error
- func (dao *OrderDao) UpdateByHash(h string, o *types.Order) error
- func (dao *OrderDao) UpdateOrderFilledAmount(hash string, value int64) error
- func (dao *OrderDao) UpdateOrderFilledAmounts(hashes []string, amount []int64) ([]*types.Order, error)
- func (dao *OrderDao) UpdateOrderStatus(h string, status string) error
- func (dao *OrderDao) UpdateOrderStatusesByHashes(status string, hashes ...string) ([]*types.Order, error)
- func (dao *OrderDao) Upsert(id bson.ObjectId, o *types.Order) error
- func (dao *OrderDao) UpsertByHash(h string, o *types.Order) error
- type OrderDaoOption
- type PairDao
- func (dao *PairDao) Create(pair *types.Pair) error
- func (dao *PairDao) GetActivePairs() ([]types.Pair, error)
- func (dao *PairDao) GetAll() ([]types.Pair, error)
- func (dao *PairDao) GetByAsset(baseToken, quoteToken string) (*types.Pair, error)
- func (dao *PairDao) GetByID(id bson.ObjectId) (*types.Pair, error)
- func (dao *PairDao) GetByName(name string) (*types.Pair, error)
- func (dao *PairDao) GetByTokenSymbols(baseTokenSymbol, quoteTokenSymbol string) (*types.Pair, error)
- func (dao *PairDao) GetDefaultPairs() ([]types.Pair, error)
- func (dao *PairDao) GetListedPairs() ([]types.Pair, error)
- func (dao *PairDao) GetUnlistedPairs() ([]types.Pair, error)
- type PairDaoOption
- type TokenDao
- func (dao *TokenDao) Create(token *types.Token) error
- func (dao *TokenDao) Drop() error
- func (dao *TokenDao) GetAll() ([]types.Token, error)
- func (dao *TokenDao) GetBaseTokens() ([]types.Token, error)
- func (dao *TokenDao) GetByAsset(asset string) (*types.Token, error)
- func (dao *TokenDao) GetByAssetOrSymbol(assetOrsymbol string) (*types.Token, error)
- func (dao *TokenDao) GetByID(id bson.ObjectId) (*types.Token, error)
- func (dao *TokenDao) GetBySymbol(symbol string) (*types.Token, error)
- func (dao *TokenDao) GetListedBaseTokens() ([]types.Token, error)
- func (dao *TokenDao) GetListedTokens() ([]types.Token, error)
- func (dao *TokenDao) GetQuoteTokens() ([]types.Token, error)
- func (dao *TokenDao) GetUnlistedTokens() ([]types.Token, error)
- type TradeDao
- func (dao *TradeDao) Aggregate(q []bson.M) ([]*types.Tick, error)
- func (dao *TradeDao) Create(trades ...*types.Trade) error
- func (dao *TradeDao) Delete(trades ...*types.Trade) error
- func (dao *TradeDao) DeleteByHashes(hashes ...string) error
- func (dao *TradeDao) Drop()
- func (dao *TradeDao) FindAndModify(h string, t *types.Trade) (*types.Trade, error)
- func (dao *TradeDao) GetAll() ([]types.Trade, error)
- func (dao *TradeDao) GetAllTradesByPairAssets(bt, qt string) ([]*types.Trade, error)
- func (dao *TradeDao) GetByHash(h string) (*types.Trade, error)
- func (dao *TradeDao) GetByHashes(hashes []string) ([]*types.Trade, error)
- func (dao *TradeDao) GetByMakerOrderHash(h string) ([]*types.Trade, error)
- func (dao *TradeDao) GetByOrderHashes(hashes []string) ([]*types.Trade, error)
- func (dao *TradeDao) GetByPairName(name string) ([]*types.Trade, error)
- func (dao *TradeDao) GetByTakerOrderHash(h string) ([]*types.Trade, error)
- func (dao *TradeDao) GetByTriggerUnitHash(h string) ([]*types.Trade, error)
- func (dao *TradeDao) GetByUserAddress(a string) ([]*types.Trade, error)
- func (dao *TradeDao) GetErroredTradeCount(start, end time.Time) (int, error)
- func (dao *TradeDao) GetNTradesByPairAssets(bt, qt string, n int) ([]*types.Trade, error)
- func (dao *TradeDao) GetSortedTrades(bt, qt string, n int) ([]*types.Trade, error)
- func (dao *TradeDao) GetSortedTradesByUserAddress(a string, limit ...int) ([]*types.Trade, error)
- func (dao *TradeDao) GetTradesByPairAssets(bt, qt string, n int) ([]*types.Trade, error)
- func (dao *TradeDao) GetUncommittedTradesByUserAddress(account string) []*types.Trade
- func (dao *TradeDao) Update(trade *types.Trade) error
- func (dao *TradeDao) UpdateByHash(h string, t *types.Trade) error
- func (dao *TradeDao) UpdateTradeStatus(h string, status string) error
- func (dao *TradeDao) UpdateTradeStatuses(status string, hashes ...string) ([]*types.Trade, error)
- func (dao *TradeDao) UpdateTradeStatusesByHashes(status string, hashes ...string) ([]*types.Trade, error)
- func (dao *TradeDao) UpdateTradeStatusesByOrderHashes(status string, hashes ...string) ([]*types.Trade, error)
- func (dao *TradeDao) Upsert(id bson.ObjectId, t *types.Trade) error
- func (dao *TradeDao) UpsertByHash(h string, t *types.Trade) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitTLSSession ¶
func NewSecureTLSSession ¶
func NewSession ¶
func NewTLSSession ¶
func OrderDaoDBOption ¶
func PairDaoDBOption ¶
Types ¶
type AccountDao ¶
type AccountDao struct {
// contains filtered or unexported fields
}
AccountDao contains: collectionName: MongoDB collection name dbName: name of mongodb to interact with
func NewAccountDao ¶
func NewAccountDao() *AccountDao
NewAccountDao returns a new instance of AccountDao
func (*AccountDao) Create ¶
func (dao *AccountDao) Create(a *types.Account) error
Create function performs the DB insertion task for Balance collection
func (*AccountDao) Drop ¶
func (dao *AccountDao) Drop()
Drop drops all the order documents in the current database
func (*AccountDao) FindOrCreate ¶
func (dao *AccountDao) FindOrCreate(addr string) (*types.Account, error)
func (*AccountDao) GetByAddress ¶
func (dao *AccountDao) GetByAddress(owner string) (*types.Account, error)
func (*AccountDao) GetTokenBalance ¶
func (dao *AccountDao) GetTokenBalance(owner string, token string) (*types.TokenBalance, error)
func (*AccountDao) GetTokenBalances ¶
func (dao *AccountDao) GetTokenBalances(owner string) (map[string]*types.TokenBalance, error)
func (*AccountDao) UpdateBalance ¶
func (dao *AccountDao) UpdateBalance(owner string, token string, balance int64) error
func (*AccountDao) UpdateTokenBalance ¶
func (dao *AccountDao) UpdateTokenBalance(owner, token string, tokenBalance *types.TokenBalance) error
type Database ¶
Database struct contains the pointer to mgo.session It is a wrapper over mgo to help utilize mgo connection pool
func (*Database) Aggregate ¶
Aggregate is a wrapper for mgo.Pipe function. It is used to make mongo aggregate pipeline queries It creates a copy of session initialized, sends query over this session and returns the session to connection pool
func (*Database) Create ¶
Create is a wrapper for mgo.Insert function. It creates a copy of session initialized, sends query over this session and returns the session to connection pool
func (*Database) DropCollection ¶
DropCollection drops all the documents in a collection
func (*Database) FindAndModify ¶
func (*Database) Get ¶
func (d *Database) Get(dbName, collection string, query interface{}, offset, limit int, response interface{}) (err error)
Get is a wrapper for mgo.Find function. It creates a copy of session initialized, sends query over this session and returns the session to connection pool
func (*Database) GetAndSort ¶
func (d *Database) GetAndSort(dbName, collection string, query interface{}, sort []string, offset, limit int, response interface{}) (err error)
GetAndSort is a wrapper for mgo.Find function with SORT function in pipeline. It creates a copy of session initialized, sends query over this session and returns the session to connection pool
func (*Database) GetByID ¶
func (d *Database) GetByID(dbName, collection string, id bson.ObjectId, response interface{}) (err error)
GetByID is a wrapper for mgo.FindId function. It creates a copy of session initialized, sends query over this session and returns the session to connection pool
func (*Database) InitDatabase ¶
func (*Database) RemoveAll ¶
RemoveAll removes all the documents from a collection matching a certain query
func (*Database) Update ¶
Update is a wrapper for mgo.Update function. It creates a copy of session initialized, sends query over this session and returns the session to connection pool
type OrderDao ¶
type OrderDao struct {
// contains filtered or unexported fields
}
OrderDao contains: collectionName: MongoDB collection name dbName: name of mongodb to interact with
func NewOrderDao ¶
func NewOrderDao(opts ...OrderDaoOption) *OrderDao
NewOrderDao returns a new instance of OrderDao
func (*OrderDao) DeleteByHashes ¶
func (*OrderDao) FindAndModify ¶
func (*OrderDao) GetByHash ¶
GetByHash function fetches a single document from order collection based on mongoDB ID. Returns Order type struct
func (*OrderDao) GetByHashes ¶
GetByHashes
func (*OrderDao) GetByID ¶
GetByID function fetches a single document from order collection based on mongoDB ID. Returns Order type struct
func (*OrderDao) GetByUserAddress ¶
GetByUserAddress function fetches list of orders from order collection based on user address. Returns array of Order type struct
func (*OrderDao) GetCurrentByUserAddress ¶
GetCurrentByUserAddress function fetches list of open/partial orders from order collection based on user address. Returns array of Order type struct
func (*OrderDao) GetCurrentByUserAddressAndSignerAddress ¶
func (*OrderDao) GetHistoryByUserAddress ¶
GetHistoryByUserAddress function fetches list of orders which are not in open/partial order status from order collection based on user address. Returns array of Order type struct
func (*OrderDao) GetMatchingBuyOrders ¶
func (*OrderDao) GetMatchingSellOrders ¶
func (*OrderDao) GetOrderBook ¶
func (*OrderDao) GetOrderBookPrice ¶
func (*OrderDao) GetRawOrderBook ¶
func (*OrderDao) GetUserLockedBalance ¶
func (*OrderDao) Update ¶
Update function performs the DB updations task for Order collection corresponding to a particular order ID
func (*OrderDao) UpdateAllByHash ¶
func (*OrderDao) UpdateByHash ¶
UpdateByHash updates fields that are considered updateable for an order.
func (*OrderDao) UpdateOrderFilledAmount ¶
func (*OrderDao) UpdateOrderFilledAmounts ¶
func (*OrderDao) UpdateOrderStatus ¶
func (*OrderDao) UpdateOrderStatusesByHashes ¶
type OrderDaoOption ¶
type PairDao ¶
type PairDao struct {
// contains filtered or unexported fields
}
PairDao contains: collectionName: MongoDB collection name dbName: name of mongodb to interact with
func NewPairDao ¶
func NewPairDao(options ...PairDaoOption) *PairDao
NewPairDao returns a new instance of PairDao
func (*PairDao) GetByAsset ¶
GetByAsset function fetches pair based on asset IDs of base token and quote token
func (*PairDao) GetByName ¶
GetByName function fetches details of a pair using pair's name. It makes CASE INSENSITIVE search query one pair's name
func (*PairDao) GetByTokenSymbols ¶
type PairDaoOption ¶
type TokenDao ¶
type TokenDao struct {
// contains filtered or unexported fields
}
TokenDao contains: collectionName: MongoDB collection name dbName: name of mongodb to interact with
func (*TokenDao) GetAll ¶
GetAll function fetches all the tokens in the token collection of mongodb.
func (*TokenDao) GetBaseTokens ¶
GetBase function fetches all the base tokens in the token collection of mongodb.
func (*TokenDao) GetByAsset ¶
GetByAsset function fetches details of a token based on its asset ID
func (*TokenDao) GetByAssetOrSymbol ¶
func (*TokenDao) GetBySymbol ¶
GetBySymbol function fetches details of a token based on its asset ID
func (*TokenDao) GetListedBaseTokens ¶
func (*TokenDao) GetQuoteTokens ¶
GetQuote function fetches all the quote tokens in the token collection of mongodb.
type TradeDao ¶
type TradeDao struct {
// contains filtered or unexported fields
}
TradeDao contains: collectionName: MongoDB collection name dbName: name of mongodb to interact with
func (*TradeDao) Create ¶
Create function performs the DB insertion task for trade collection It accepts 1 or more trades as input. All the trades are inserted in one query itself.
func (*TradeDao) DeleteByHashes ¶
func (*TradeDao) Drop ¶
func (dao *TradeDao) Drop()
Drop drops all the order documents in the current database
func (*TradeDao) FindAndModify ¶
func (*TradeDao) GetAllTradesByPairAssets ¶
func (*TradeDao) GetByHashes ¶
func (*TradeDao) GetByMakerOrderHash ¶
GetByOrderHash fetches the first trade record which matches a certain order hash
func (*TradeDao) GetByOrderHashes ¶
func (*TradeDao) GetByPairName ¶
GetByPairName fetches all the trades corresponding to a particular pair name.
func (*TradeDao) GetByTakerOrderHash ¶
func (*TradeDao) GetByTriggerUnitHash ¶
func (*TradeDao) GetByUserAddress ¶
GetByUserAddress fetches all the trades corresponding to a particular user address.
func (*TradeDao) GetErroredTradeCount ¶
func (*TradeDao) GetNTradesByPairAssets ¶
func (*TradeDao) GetSortedTrades ¶
func (*TradeDao) GetSortedTradesByUserAddress ¶
func (*TradeDao) GetTradesByPairAssets ¶
GetByPairAssets fetches all the trades corresponding to a particular pair token assets.
func (*TradeDao) GetUncommittedTradesByUserAddress ¶
func (*TradeDao) UpdateByHash ¶
UpdateByHash updates the fields that can be normally updated in a structure. For a complete update, use the Update or UpdateAllByHash function