func (db *DB) GetOrdersForPubkey(pubkey *koblitz.PublicKey) (orders []*match.LimitOrder, err error) {
	tx, err := db.DBHandler.Begin()
	if err != nil {
		err = fmt.Errorf("Error cancelling order: \n%s", err)
		return
	}
	defer func() {
		if err != nil {
			tx.Rollback()
			err = fmt.Errorf("Error while cancelling order: \n%s", err)
			return
		}
		err = tx.Commit()
	}()

	if _, err = tx.Exec("USE " + db.orderSchema + ";"); err != nil {
		return
	}

	for _, pair := range db.pairsArray {
		// figure out if there is even an order
		getCurrentOrderQuery := fmt.Sprintf("SELECT orderID, amountHave, amountWant, side, timestamp, price FROM %s WHERE pubkey='%x';", pair.String(), pubkey.SerializeCompressed())
		rows, currOrderErr := tx.Query(getCurrentOrderQuery)
		if err = currOrderErr; err != nil {
			return
		}

		for rows.Next() {
			var order *match.LimitOrder

			if err = rows.Scan(&order.OrderID, &order.AmountHave, &order.AmountWant, &order.Side, &order.Timestamp, &order.OrderbookPrice); err != nil {
				return
			}

			// copy pubkey bytes into 33 order byte arr
			copy(order.Pubkey[:], pubkey.SerializeCompressed())
			order.TradingPair = *pair

			orders = append(orders, order)

		}
		// do this so we don't get bad connection / busy buffer issues
		if err = rows.Close(); err != nil {
			return
		}
	}

	return
}
// GetOrdersForPubkey gets orders for a specific pubkey
GetOrdersForPubkey gets orders for a specific pubkey
// GetOrdersForPubkey gets orders for a specific pubkey
func (db *DB) GetOrdersForPubkey(pubkey *koblitz.PublicKey) (orders []*match.LimitOrder, err error) {
	tx, err := db.DBHandler.Begin()
	if err != nil {
		err = fmt.Errorf("Error cancelling order: \n%s", err)
		return
	}
	defer func() {
		if err != nil {
			tx.Rollback()
			err = fmt.Errorf("Error while cancelling order: \n%s", err)
			return
		}
		err = tx.Commit()
	}()
	if _, err = tx.Exec("USE " + db.orderSchema + ";"); err != nil {
		return
	}
	for _, pair := range db.pairsArray {
		getCurrentOrderQuery := fmt.Sprintf("SELECT orderID, amountHave, amountWant, side, timestamp, price FROM %s WHERE pubkey='%x';", pair.String(), pubkey.SerializeCompressed())
		rows, currOrderErr := tx.Query(getCurrentOrderQuery)
		if err = currOrderErr; err != nil {
			return
		}
		for rows.Next() {
			var order *match.LimitOrder
			if err = rows.Scan(&order.OrderID, &order.AmountHave, &order.AmountWant, &order.Side, &order.Timestamp, &order.OrderbookPrice); err != nil {
				return
			}
			copy(order.Pubkey[:], pubkey.SerializeCompressed())
			order.TradingPair = *pair
			orders = append(orders, order)
		}
		if err = rows.Close(); err != nil {
			return
		}
	}
	return
}
func ( db * DB ) GetOrdersForPubkey ( pubkey * koblitz . PublicKey ) ( orders [ ] * match . LimitOrder , err error ) { tx , err := db . DBHandler . Begin ( ) if err != nil { err = fmt . Errorf ( " \n " , err ) return } defer func ( ) { if err != nil { tx . Rollback ( ) err = fmt . Errorf ( " \n " , err ) return } err = tx . Commit ( ) } ( ) if _ , err = tx . Exec ( " " + db . orderSchema + " " ) ; err != nil { return } for _ , pair := range db . pairsArray { getCurrentOrderQuery := fmt . Sprintf ( " " , pair . String ( ) , pubkey . SerializeCompressed ( ) ) rows , currOrderErr := tx . Query ( getCurrentOrderQuery ) if err = currOrderErr ; err != nil { return } for rows . Next ( ) { var order * match . LimitOrder if err = rows . Scan ( & order . OrderID , & order . AmountHave , & order . AmountWant , & order . Side , & order . Timestamp , & order . OrderbookPrice ) ; err != nil { return } copy ( order . Pubkey [ : ] , pubkey . SerializeCompressed ( ) ) order . TradingPair = * pair orders = append ( orders , order ) } if err = rows . Close ( ) ; err != nil { return } } return }
GetOrdersForPubkey gets orders for a specific pubkey
GetOrdersForPubkey gets orders for a specific pubkey
// figure out if there is even an order // copy pubkey bytes into 33 order byte arr // do this so we don't get bad connection / busy buffer issues