func (db *DB) SetupClient(coinList []*coinparam.Params) (err error) {
	db.gPriceMap = make(map[string]float64)
	db.balanceSchema = balanceSchema
	db.depositSchema = depositSchema
	db.pendingDepositSchema = pendingDepositSchema
	db.orderSchema = orderSchema
	db.peerSchema = peerSchema
	db.peerTableName = peerTableName
	db.puzzleSchema = puzzleSchema
	db.puzzleTable = puzzleTable
	db.auctionSchema = auctionSchema
	db.auctionOrderSchema = auctionOrderSchema
	db.auctionOrderTable = auctionOrderTable
	// Create users and schemas and assign permissions to opencx
	if err = db.rootInitSchemas(); err != nil {
		err = fmt.Errorf("Root could not initialize schemas: \n%s", err)
		return
	}

	// open db handle
	openString := fmt.Sprintf("%s:%s@%s(%s)/", db.dbUsername, db.dbPassword, db.dbAddr.Network(), db.dbAddr.String())

	var dbHandle *sql.DB
	if dbHandle, err = sql.Open("mysql", openString); err != nil {
		err = fmt.Errorf("Error opening database: \n%s", err)
		return
	}

	db.DBHandler = dbHandle
	db.coinList = coinList

	// Get all the pairs
	if db.pairsArray, err = match.GenerateAssetPairs(coinList); err != nil {
		return
	}

	// DEBUGGING

	// Get all the assets
	for i, asset := range db.coinList {
		logging.Debugf("Asset %d: %s\n", i, asset.Name)
	}

	// Get all the asset pairs
	for i, pair := range db.pairsArray {
		logging.Debugf("Pair %d: %s\n", i, pair)
	}
	// END DEBUGGING

	if err = db.DBHandler.Ping(); err != nil {
		err = fmt.Errorf("Could not ping the database, is it running: %s", err)
		return
	}

	if err = db.SetupCustodyTables(db.balanceSchema, db.depositSchema, db.pendingDepositSchema); err != nil {
		err = fmt.Errorf("Error setting up custody tables: %s", err)
		return
	}

	if err = db.SetupExchangeTables(db.orderSchema); err != nil {
		err = fmt.Errorf("Error setting up exchange tables: %s", err)
		return
	}

	if err = db.SetupAuctionTables(db.auctionSchema, db.puzzleSchema, db.puzzleTable, db.auctionOrderSchema, db.auctionOrderTable); err != nil {
		err = fmt.Errorf("Error setting up auction tables: %s", err)
		return
	}

	return
}
// SetupClient sets up the mysql client and driver
SetupClient sets up the mysql client and driver
// SetupClient sets up the mysql client and driver
func (db *DB) SetupClient(coinList []*coinparam.Params) (err error) {
	db.gPriceMap = make(map[string]float64)
	db.balanceSchema = balanceSchema
	db.depositSchema = depositSchema
	db.pendingDepositSchema = pendingDepositSchema
	db.orderSchema = orderSchema
	db.peerSchema = peerSchema
	db.peerTableName = peerTableName
	db.puzzleSchema = puzzleSchema
	db.puzzleTable = puzzleTable
	db.auctionSchema = auctionSchema
	db.auctionOrderSchema = auctionOrderSchema
	db.auctionOrderTable = auctionOrderTable
	if err = db.rootInitSchemas(); err != nil {
		err = fmt.Errorf("Root could not initialize schemas: \n%s", err)
		return
	}
	openString := fmt.Sprintf("%s:%s@%s(%s)/", db.dbUsername, db.dbPassword, db.dbAddr.Network(), db.dbAddr.String())
	var dbHandle *sql.DB
	if dbHandle, err = sql.Open("mysql", openString); err != nil {
		err = fmt.Errorf("Error opening database: \n%s", err)
		return
	}
	db.DBHandler = dbHandle
	db.coinList = coinList
	if db.pairsArray, err = match.GenerateAssetPairs(coinList); err != nil {
		return
	}
	for i, asset := range db.coinList {
		logging.Debugf("Asset %d: %s\n", i, asset.Name)
	}
	for i, pair := range db.pairsArray {
		logging.Debugf("Pair %d: %s\n", i, pair)
	}
	if err = db.DBHandler.Ping(); err != nil {
		err = fmt.Errorf("Could not ping the database, is it running: %s", err)
		return
	}
	if err = db.SetupCustodyTables(db.balanceSchema, db.depositSchema, db.pendingDepositSchema); err != nil {
		err = fmt.Errorf("Error setting up custody tables: %s", err)
		return
	}
	if err = db.SetupExchangeTables(db.orderSchema); err != nil {
		err = fmt.Errorf("Error setting up exchange tables: %s", err)
		return
	}
	if err = db.SetupAuctionTables(db.auctionSchema, db.puzzleSchema, db.puzzleTable, db.auctionOrderSchema, db.auctionOrderTable); err != nil {
		err = fmt.Errorf("Error setting up auction tables: %s", err)
		return
	}
	return
}
func ( db * DB ) SetupClient ( coinList [ ] * coinparam . Params ) ( err error ) { db . gPriceMap = make ( map [ string ] float64 ) db . balanceSchema = balanceSchema db . depositSchema = depositSchema db . pendingDepositSchema = pendingDepositSchema db . orderSchema = orderSchema db . peerSchema = peerSchema db . peerTableName = peerTableName db . puzzleSchema = puzzleSchema db . puzzleTable = puzzleTable db . auctionSchema = auctionSchema db . auctionOrderSchema = auctionOrderSchema db . auctionOrderTable = auctionOrderTable if err = db . rootInitSchemas ( ) ; err != nil { err = fmt . Errorf ( " \n " , err ) return } openString := fmt . Sprintf ( " " , db . dbUsername , db . dbPassword , db . dbAddr . Network ( ) , db . dbAddr . String ( ) ) var dbHandle * sql . DB if dbHandle , err = sql . Open ( " " , openString ) ; err != nil { err = fmt . Errorf ( " \n " , err ) return } db . DBHandler = dbHandle db . coinList = coinList if db . pairsArray , err = match . GenerateAssetPairs ( coinList ) ; err != nil { return } for i , asset := range db . coinList { logging . Debugf ( " \n " , i , asset . Name ) } for i , pair := range db . pairsArray { logging . Debugf ( " \n " , i , pair ) } if err = db . DBHandler . Ping ( ) ; err != nil { err = fmt . Errorf ( " " , err ) return } if err = db . SetupCustodyTables ( db . balanceSchema , db . depositSchema , db . pendingDepositSchema ) ; err != nil { err = fmt . Errorf ( " " , err ) return } if err = db . SetupExchangeTables ( db . orderSchema ) ; err != nil { err = fmt . Errorf ( " " , err ) return } if err = db . SetupAuctionTables ( db . auctionSchema , db . puzzleSchema , db . puzzleTable , db . auctionOrderSchema , db . auctionOrderTable ) ; err != nil { err = fmt . Errorf ( " " , err ) return } return }
SetupClient sets up the mysql client and driver
SetupClient sets up the mysql client and driver
// Create users and schemas and assign permissions to opencx // open db handle // Get all the pairs // DEBUGGING // Get all the assets // Get all the asset pairs // END DEBUGGING