daos

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitSession

func InitSession(session *mgo.Session) (*mgo.Session, error)

InitSession initializes a new session with mongodb

func OrderDaoDBOption

func OrderDaoDBOption(dbName string) func(dao *OrderDao) error

func PairDaoDBOption

func PairDaoDBOption(dbName string) func(dao *PairDao) error

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 AddressDao

func (*AccountDao) AddFavoriteToken

func (dao *AccountDao) AddFavoriteToken(owner, token common.Address) error

func (*AccountDao) Create

func (dao *AccountDao) Create(a *types.Account) error

Create function performs the DB insertion task for Balance collection

func (*AccountDao) DeleteFavoriteToken

func (dao *AccountDao) DeleteFavoriteToken(owner, token common.Address) error

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 common.Address) (*types.Account, error)

func (*AccountDao) GetAll

func (dao *AccountDao) GetAll() (res []types.Account, err error)

func (*AccountDao) GetByAddress

func (dao *AccountDao) GetByAddress(owner common.Address) (*types.Account, error)

func (*AccountDao) GetByID

func (dao *AccountDao) GetByID(id bson.ObjectId) (*types.Account, error)

func (*AccountDao) GetFavoriteTokens

func (dao *AccountDao) GetFavoriteTokens(owner common.Address) (map[common.Address]bool, error)

func (*AccountDao) GetTokenBalance

func (dao *AccountDao) GetTokenBalance(owner common.Address, token common.Address) (*types.TokenBalance, error)

func (*AccountDao) GetTokenBalances

func (dao *AccountDao) GetTokenBalances(owner common.Address) (map[common.Address]*types.TokenBalance, error)

func (*AccountDao) Transfer

func (dao *AccountDao) Transfer(token common.Address, fromAddress common.Address, toAddress common.Address, amount *big.Int) error

func (*AccountDao) UpdateBalance

func (dao *AccountDao) UpdateBalance(owner common.Address, token common.Address, balance *big.Int) error

func (*AccountDao) UpdateTokenBalance

func (dao *AccountDao) UpdateTokenBalance(owner, token common.Address, tokenBalance *types.TokenBalance) error

type AssociationDao

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

AssociationDao contains: collectionName: MongoDB collection name dbName: name of mongodb to interact with

func NewAssociationDao

func NewAssociationDao() *AssociationDao

NewBalanceDao returns a new instance of AddressDao

func (*AssociationDao) Drop

func (dao *AssociationDao) Drop()

Drop drops all the order documents in the current database

func (*AssociationDao) GetAssociationByChainAddress

func (dao *AssociationDao) GetAssociationByChainAddress(chain types.Chain, userAddress common.Address) (*types.AddressAssociationRecord, error)

func (*AssociationDao) GetAssociationByChainAssociatedAddress

func (dao *AssociationDao) GetAssociationByChainAssociatedAddress(chain types.Chain, associatedAddress common.Address) (*types.AddressAssociationRecord, error)

func (*AssociationDao) SaveAssociation

func (dao *AssociationDao) SaveAssociation(record *types.AddressAssociationRecord) error

SaveAssociation using upsert to update for existing users, only update allowed fields

func (*AssociationDao) SaveAssociationStatus

func (dao *AssociationDao) SaveAssociationStatus(chain types.Chain, sourceAccount common.Address, status string) error

func (*AssociationDao) SaveDepositTransaction

func (dao *AssociationDao) SaveDepositTransaction(chain types.Chain, sourceAccount common.Address, txEnvelope string) error

SaveDepositTransaction update the transaction envelope for association item

type ConfigDao

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

ConfigDao contains: collectionName: MongoDB collection name dbName: name of mongodb to interact with

func NewConfigDao

func NewConfigDao() *ConfigDao

NewBalanceDao returns a new instance of AddressDao

func (*ConfigDao) Drop

func (dao *ConfigDao) Drop()

Drop drops all the order documents in the current database

func (*ConfigDao) GetAddressIndex

func (dao *ConfigDao) GetAddressIndex(chain types.Chain) (uint64, error)

func (*ConfigDao) GetBlockToProcess

func (dao *ConfigDao) GetBlockToProcess(chain types.Chain) (uint64, error)

func (*ConfigDao) GetSchemaVersion

func (dao *ConfigDao) GetSchemaVersion() uint64

func (*ConfigDao) IncrementAddressIndex

func (dao *ConfigDao) IncrementAddressIndex(chain types.Chain) error

func (*ConfigDao) ResetBlockCounters

func (dao *ConfigDao) ResetBlockCounters() error

ResetBlockCounters changes last processed bitcoin and ethereum block to default value. Used in stress tests.

func (*ConfigDao) SaveLastProcessedBlock

func (dao *ConfigDao) SaveLastProcessedBlock(chain types.Chain, block uint64) error

type Database

type Database struct {
	Session *mgo.Session
}

Database struct contains the pointer to mgo.session It is a wrapper over mgo to help utilize mgo connection pool

func (*Database) Aggregate

func (d *Database) Aggregate(dbName, collection string, query []bson.M, response interface{}) error

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

func (d *Database) Create(dbName, collection string, data ...interface{}) (err error)

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

func (d *Database) DropCollection(dbName, collection string) error

DropCollection drops all the documents in a collection

func (*Database) FindAndModify

func (d *Database) FindAndModify(dbName, collection string, query interface{}, change mgo.Change, response interface{}) error

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) GetOne

func (d *Database) GetOne(dbName, collection string, query interface{}, response interface{}) (err error)

GetOne return one document

func (*Database) InitDatabase

func (d *Database) InitDatabase(session *mgo.Session)

func (*Database) Query

func (d *Database) Query(dbName, collection string, query interface{}, selector interface{}, offset, limit int, response interface{}) (err error)

func (*Database) Remove

func (d *Database) Remove(dbName, collection string, query []bson.M) error

Remove removes one document matching a certain query

func (*Database) RemoveAll

func (d *Database) RemoveAll(dbName, collection string, query interface{}) error

RemoveAll removes all the documents from a collection matching a certain query

func (*Database) Update

func (d *Database) Update(dbName, collection string, query interface{}, update interface{}) error

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

func (*Database) UpdateAll

func (d *Database) UpdateAll(dbName, collection string, query interface{}, update interface{}) error

func (*Database) Upsert

func (d *Database) Upsert(dbName, collection string, query interface{}, update interface{}) (interface{}, error)

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) Aggregate

func (dao *OrderDao) Aggregate(q []bson.M) ([]*types.OrderData, error)

Aggregate function calls the aggregate pipeline of mongodb

func (*OrderDao) Create

func (dao *OrderDao) Create(o *types.Order) error

Create function performs the DB insertion task for Order collection

func (*OrderDao) Delete

func (dao *OrderDao) Delete(orders ...*types.Order) error

func (*OrderDao) DeleteByHashes

func (dao *OrderDao) DeleteByHashes(hashes ...common.Hash) error

func (*OrderDao) Drop

func (dao *OrderDao) Drop() error

Drop drops all the order documents in the current database

func (*OrderDao) FindAndModify

func (dao *OrderDao) FindAndModify(h common.Hash, o *types.Order) (*types.Order, error)

func (*OrderDao) GetByHash

func (dao *OrderDao) GetByHash(hash common.Hash) (*types.Order, error)

GetByHash function fetches a single document from order collection based on mongoDB ID. Returns Order type struct

func (*OrderDao) GetByHashes

func (dao *OrderDao) GetByHashes(hashes []common.Hash) ([]*types.Order, error)

GetByHashes

func (*OrderDao) GetByID

func (dao *OrderDao) GetByID(id bson.ObjectId) (*types.Order, error)

GetByID function fetches a single document from order collection based on mongoDB ID. Returns Order type struct

func (*OrderDao) GetByUserAddress

func (dao *OrderDao) GetByUserAddress(addr common.Address, limit ...int) ([]*types.Order, error)

GetByUserAddress function fetches list of orders from order collection based on user address. Returns array of Order type struct

func (*OrderDao) GetCurrentByUserAddress

func (dao *OrderDao) GetCurrentByUserAddress(addr common.Address, limit ...int) ([]*types.Order, error)

GetCurrentByUserAddress function fetches list of open/partial orders from order collection based on user address. Returns array of Order type struct

func (*OrderDao) GetHistoryByUserAddress

func (dao *OrderDao) GetHistoryByUserAddress(addr common.Address, limit ...int) ([]*types.Order, error)

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 (dao *OrderDao) GetMatchingBuyOrders(o *types.Order) ([]*types.Order, error)

func (*OrderDao) GetMatchingSellOrders

func (dao *OrderDao) GetMatchingSellOrders(o *types.Order) ([]*types.Order, error)

func (*OrderDao) GetOrderBook

func (dao *OrderDao) GetOrderBook(p *types.Pair) ([]map[string]string, []map[string]string, error)

GetOrderBook get best bids descending and best asks ascending

func (*OrderDao) GetOrderBookPricePoint

func (dao *OrderDao) GetOrderBookPricePoint(p *types.Pair, pp *big.Int, side string) (*big.Int, error)

func (*OrderDao) GetRawOrderBook

func (dao *OrderDao) GetRawOrderBook(p *types.Pair) ([]*types.Order, error)

func (*OrderDao) GetSideOrderBook

func (dao *OrderDao) GetSideOrderBook(p *types.Pair, side string, sort int, limit ...int) ([]map[string]string, error)

func (*OrderDao) GetUserLockedBalance

func (dao *OrderDao) GetUserLockedBalance(account common.Address, token common.Address, p *types.Pair) (*big.Int, error)

func (*OrderDao) Update

func (dao *OrderDao) Update(id bson.ObjectId, o *types.Order) error

Update function performs the DB updations task for Order collection corresponding to a particular order ID

func (*OrderDao) UpdateAllByHash

func (dao *OrderDao) UpdateAllByHash(h common.Hash, o *types.Order) error

func (*OrderDao) UpdateByHash

func (dao *OrderDao) UpdateByHash(h common.Hash, o *types.Order) error

UpdateByHash updates fields that are considered updateable for an order.

func (*OrderDao) UpdateOrderFilledAmount

func (dao *OrderDao) UpdateOrderFilledAmount(hash common.Hash, value *big.Int) error

func (*OrderDao) UpdateOrderFilledAmounts

func (dao *OrderDao) UpdateOrderFilledAmounts(hashes []common.Hash, amount []*big.Int) ([]*types.Order, error)

func (*OrderDao) UpdateOrderStatus

func (dao *OrderDao) UpdateOrderStatus(h common.Hash, status string) error

func (*OrderDao) UpdateOrderStatusesByHashes

func (dao *OrderDao) UpdateOrderStatusesByHashes(status string, hashes ...common.Hash) ([]*types.Order, error)

func (*OrderDao) Upsert

func (dao *OrderDao) Upsert(id bson.ObjectId, o *types.Order) error

func (*OrderDao) UpsertByHash

func (dao *OrderDao) UpsertByHash(h common.Hash, o *types.Order) error

type OrderDaoOption

type OrderDaoOption = func(*OrderDao) error

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 AddressDao

func (*PairDao) Create

func (dao *PairDao) Create(pair *types.Pair) error

Create function performs the DB insertion task for pair collection

func (*PairDao) GetActivePairs

func (dao *PairDao) GetActivePairs() ([]*types.Pair, error)

func (*PairDao) GetAll

func (dao *PairDao) GetAll() ([]types.Pair, error)

GetAll function fetches all the pairs in the pair collection of mongodb. for GetAll return continous memory

func (*PairDao) GetByID

func (dao *PairDao) GetByID(id bson.ObjectId) (*types.Pair, error)

GetByID function fetches details of a pair using pair's mongo ID.

func (*PairDao) GetByName

func (dao *PairDao) GetByName(name string) (*types.Pair, error)

GetByName function fetches details of a pair using pair's name. It makes CASE INSENSITIVE search query one pair's name

func (*PairDao) GetByTokenAddress

func (dao *PairDao) GetByTokenAddress(baseToken, quoteToken common.Address) (*types.Pair, error)

GetByTokenAddress function fetches pair based on CONTRACT ADDRESS of base token and quote token

func (*PairDao) GetByTokenSymbols

func (dao *PairDao) GetByTokenSymbols(baseTokenSymbol, quoteTokenSymbol string) (*types.Pair, error)

func (*PairDao) GetListedPairs

func (dao *PairDao) GetListedPairs() ([]types.Pair, error)

func (*PairDao) GetUnlistedPairs

func (dao *PairDao) GetUnlistedPairs() ([]types.Pair, error)

type PairDaoOption

type PairDaoOption = func(*PairDao) error

type PriceBoardDao

type PriceBoardDao struct {
}

func NewPriceBoardDao

func NewPriceBoardDao() *PriceBoardDao

NewTokenDao returns a new instance of TokenDao.

func (*PriceBoardDao) GetLatestQuotes

func (dao *PriceBoardDao) GetLatestQuotes() (map[string]float64, error)

type TokenDao

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

TokenDao contains: collectionName: MongoDB collection name dbName: name of mongodb to interact with

func NewTokenDao

func NewTokenDao() *TokenDao

NewTokenDao returns a new instance of TokenDao.

func (*TokenDao) Create

func (dao *TokenDao) Create(token *types.Token) error

Create function performs the DB insertion task for token collection

func (*TokenDao) Drop

func (dao *TokenDao) Drop() error

Drop drops all the order documents in the current database

func (*TokenDao) GetAll

func (dao *TokenDao) GetAll() ([]types.Token, error)

GetAll function fetches all the tokens in the token collection of mongodb.

func (*TokenDao) GetBaseTokens

func (dao *TokenDao) GetBaseTokens() ([]types.Token, error)

GetBase function fetches all the base tokens in the token collection of mongodb.

func (*TokenDao) GetByAddress

func (dao *TokenDao) GetByAddress(addr common.Address) (*types.Token, error)

GetByAddress function fetches details of a token based on its contract address

func (*TokenDao) GetByID

func (dao *TokenDao) GetByID(id bson.ObjectId) (*types.Token, error)

GetByID function fetches details of a token based on its mongo id

func (*TokenDao) GetQuoteTokens

func (dao *TokenDao) GetQuoteTokens() ([]types.Token, error)

GetQuote function fetches all the quote tokens in the token collection of mongodb.

func (*TokenDao) UpdateFiatPriceBySymbol

func (dao *TokenDao) UpdateFiatPriceBySymbol(symbol string, price float64) error

type TradeDao

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

TradeDao contains: collectionName: MongoDB collection name dbName: name of mongodb to interact with

func NewTradeDao

func NewTradeDao() *TradeDao

NewTradeDao returns a new instance of TradeDao.

func (*TradeDao) Aggregate

func (dao *TradeDao) Aggregate(q []bson.M) ([]*types.Tick, error)

Aggregate function calls the aggregate pipeline of mongodb

func (*TradeDao) Create

func (dao *TradeDao) Create(trades ...*types.Trade) error

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) Delete

func (dao *TradeDao) Delete(trades ...*types.Trade) error

func (*TradeDao) DeleteByHashes

func (dao *TradeDao) DeleteByHashes(hashes ...common.Hash) error

func (*TradeDao) Drop

func (dao *TradeDao) Drop()

Drop drops all the order documents in the current database

func (*TradeDao) FindAndModify

func (dao *TradeDao) FindAndModify(h common.Hash, t *types.Trade) (*types.Trade, error)

func (*TradeDao) GetAll

func (dao *TradeDao) GetAll() ([]types.Trade, error)

GetAll function fetches all the trades in mongodb

func (*TradeDao) GetAllTradesByPairAddress

func (dao *TradeDao) GetAllTradesByPairAddress(bt, qt common.Address) ([]*types.Trade, error)

func (*TradeDao) GetByHash

func (dao *TradeDao) GetByHash(h common.Hash) (*types.Trade, error)

GetByHash fetches the first record that matches a certain hash

func (*TradeDao) GetByMakerOrderHash

func (dao *TradeDao) GetByMakerOrderHash(h common.Hash) ([]*types.Trade, error)

GetByOrderHash fetches the first trade record which matches a certain order hash

func (*TradeDao) GetByOrderHashes

func (dao *TradeDao) GetByOrderHashes(hashes []common.Hash) ([]*types.Trade, error)

func (*TradeDao) GetByPairName

func (dao *TradeDao) GetByPairName(name string) ([]*types.Trade, error)

GetByPairName fetches all the trades corresponding to a particular pair name.

func (*TradeDao) GetByTakerOrderHash

func (dao *TradeDao) GetByTakerOrderHash(h common.Hash) ([]*types.Trade, error)

func (*TradeDao) GetByUserAddress

func (dao *TradeDao) GetByUserAddress(a common.Address) ([]*types.Trade, error)

GetByUserAddress fetches all the trades corresponding to a particular user address.

func (*TradeDao) GetLatestTrade

func (dao *TradeDao) GetLatestTrade(bt, qt common.Address) (*types.Trade, error)

func (*TradeDao) GetNTradesByPairAddress

func (dao *TradeDao) GetNTradesByPairAddress(bt, qt common.Address, n int) ([]*types.Trade, error)

func (*TradeDao) GetSortedTrades

func (dao *TradeDao) GetSortedTrades(bt, qt common.Address, n int) ([]*types.Trade, error)

func (*TradeDao) GetSortedTradesByUserAddress

func (dao *TradeDao) GetSortedTradesByUserAddress(a common.Address, limit ...int) ([]*types.Trade, error)

func (*TradeDao) GetTradesByPairAddress

func (dao *TradeDao) GetTradesByPairAddress(bt, qt common.Address, n int) ([]*types.Trade, error)

GetByPairAddress fetches all the trades corresponding to a particular pair token address.

func (*TradeDao) Update

func (dao *TradeDao) Update(trade *types.Trade) error

func (*TradeDao) UpdateByHash

func (dao *TradeDao) UpdateByHash(h common.Hash, t *types.Trade) error

UpdateByHash updates the fields that can be normally updated in a structure. For a complete update, use the Update or UpdateAllByHash function

func (*TradeDao) UpdateTradeStatus

func (dao *TradeDao) UpdateTradeStatus(h common.Hash, status string) error

func (*TradeDao) UpdateTradeStatuses

func (dao *TradeDao) UpdateTradeStatuses(status string, hashes ...common.Hash) ([]*types.Trade, error)

func (*TradeDao) UpdateTradeStatusesByHashes

func (dao *TradeDao) UpdateTradeStatusesByHashes(status string, hashes ...common.Hash) ([]*types.Trade, error)

func (*TradeDao) UpdateTradeStatusesByOrderHashes

func (dao *TradeDao) UpdateTradeStatusesByOrderHashes(status string, hashes ...common.Hash) ([]*types.Trade, error)

func (*TradeDao) Upsert

func (dao *TradeDao) Upsert(id bson.ObjectId, t *types.Trade) error

func (*TradeDao) UpsertByHash

func (dao *TradeDao) UpsertByHash(h common.Hash, t *types.Trade) error

type WalletDao

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

TokenDao contains: collectionName: MongoDB collection name dbName: name of mongodb to interact with

func NewWalletDao

func NewWalletDao() *WalletDao

func (*WalletDao) Create

func (dao *WalletDao) Create(wallet *types.Wallet) error

func (*WalletDao) GetAll

func (dao *WalletDao) GetAll() ([]types.Wallet, error)

func (*WalletDao) GetByAddress

func (dao *WalletDao) GetByAddress(a common.Address) (*types.Wallet, error)

GetByAddress function fetches details of a token based on its contract address

func (*WalletDao) GetByID

func (dao *WalletDao) GetByID(id bson.ObjectId) (*types.Wallet, error)

GetByID function fetches details of a token based on its mongo id

func (*WalletDao) GetDefaultAdminWallet

func (dao *WalletDao) GetDefaultAdminWallet() (*types.Wallet, error)

func (*WalletDao) GetOperatorWallets

func (dao *WalletDao) GetOperatorWallets() ([]*types.Wallet, error)

Jump to

Keyboard shortcuts

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