func (db *DB) GetOrder(orderID string) (order *match.LimitOrder, err error) {
	tx, err := db.DBHandler.Begin()
	if err != nil {
		err = fmt.Errorf("Error getting order: \n%s", err)
		return
	}
	defer func() {
		if err != nil {
			tx.Rollback()
			err = fmt.Errorf("Error while getting 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 pubkey, amountHave, amountWant, side, timestamp, price FROM %s WHERE orderID='%s';", pair.String(), orderID)
		rows, currOrderErr := tx.Query(getCurrentOrderQuery)
		if err = currOrderErr; err != nil {
			return
		}

		if rows.Next() {
			var pubkeyBytes []byte
			if err = rows.Scan(&pubkeyBytes, &order.AmountHave, &order.AmountWant, &order.Side, &order.Timestamp, &order.OrderbookPrice); err != nil {
				return
			}

			// we have to do this because ugh they return my byte arrays as hex strings...
			if pubkeyBytes, err = hex.DecodeString(string(pubkeyBytes)); err != nil {
				return
			}

			// copy pubkey bytes into 33 order byte arr
			copy(order.Pubkey[:], pubkeyBytes)

			order.TradingPair = *pair
			order.OrderID = orderID

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

	if order != nil {
		err = fmt.Errorf("Order does not exist in any orderbook")
		return
	}

	return
}
// GetOrder gets an order for a specific order ID
GetOrder gets an order for a specific order ID
// GetOrder gets an order for a specific order ID
func (db *DB) GetOrder(orderID string) (order *match.LimitOrder, err error) {
	tx, err := db.DBHandler.Begin()
	if err != nil {
		err = fmt.Errorf("Error getting order: \n%s", err)
		return
	}
	defer func() {
		if err != nil {
			tx.Rollback()
			err = fmt.Errorf("Error while getting 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 pubkey, amountHave, amountWant, side, timestamp, price FROM %s WHERE orderID='%s';", pair.String(), orderID)
		rows, currOrderErr := tx.Query(getCurrentOrderQuery)
		if err = currOrderErr; err != nil {
			return
		}
		if rows.Next() {
			var pubkeyBytes []byte
			if err = rows.Scan(&pubkeyBytes, &order.AmountHave, &order.AmountWant, &order.Side, &order.Timestamp, &order.OrderbookPrice); err != nil {
				return
			}
			if pubkeyBytes, err = hex.DecodeString(string(pubkeyBytes)); err != nil {
				return
			}
			copy(order.Pubkey[:], pubkeyBytes)
			order.TradingPair = *pair
			order.OrderID = orderID
		}
		if err = rows.Close(); err != nil {
			return
		}
	}
	if order != nil {
		err = fmt.Errorf("Order does not exist in any orderbook")
		return
	}
	return
}
func ( db * DB ) GetOrder ( orderID string ) ( order * 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 ( ) , orderID ) rows , currOrderErr := tx . Query ( getCurrentOrderQuery ) if err = currOrderErr ; err != nil { return } if rows . Next ( ) { var pubkeyBytes [ ] byte if err = rows . Scan ( & pubkeyBytes , & order . AmountHave , & order . AmountWant , & order . Side , & order . Timestamp , & order . OrderbookPrice ) ; err != nil { return } if pubkeyBytes , err = hex . DecodeString ( string ( pubkeyBytes ) ) ; err != nil { return } copy ( order . Pubkey [ : ] , pubkeyBytes ) order . TradingPair = * pair order . OrderID = orderID } if err = rows . Close ( ) ; err != nil { return } } if order != nil { err = fmt . Errorf ( " " ) return } return }
GetOrder gets an order for a specific order ID
GetOrder gets an order for a specific order ID
// figure out if there is even an order // we have to do this because ugh they return my byte arrays as hex strings... // copy pubkey bytes into 33 order byte arr // do this so we don't get bad connection / busy buffer issues