Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
Fixed bug that was generating infinite number of orders.
  • Loading branch information
nicehashdev committed Feb 6, 2015
1 parent cb43811 commit c845e9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/NiceHashBotLib/APIWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,13 @@ public static APIBalance GetBalance()
/// </summary>
/// <param name="ServiceLocation">Service location; 0 for NiceHash, 1 for WestHash.</param>
/// <param name="Algorithm">Algorithm number.</param>
/// <param name="ForceReCache">Set this to true to recache order list.</param>
/// <returns>Array list of orders.</returns>
public static List<Order> GetAllOrders(int ServiceLocation, int Algorithm)
public static List<Order> GetAllOrders(int ServiceLocation, int Algorithm, bool ForceReCache)
{
lock (CacheLock)
{
if (CachedOList[ServiceLocation, Algorithm] == null || (CachedOList[ServiceLocation, Algorithm].ObtainTime + TimeSpan.FromSeconds(29.0) < DateTime.Now))
if (ForceReCache || CachedOList[ServiceLocation, Algorithm] == null || (CachedOList[ServiceLocation, Algorithm].ObtainTime + TimeSpan.FromSeconds(29.0) < DateTime.Now))
{
CachedOList[ServiceLocation, Algorithm] = new CachedOrderList();
CachedOList[ServiceLocation, Algorithm].OrderList = GetOrders(ServiceLocation, Algorithm, "orders.get", false);
Expand Down
7 changes: 6 additions & 1 deletion src/NiceHashBotLib/OrderInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,24 @@ private void ThreadRun()

lock (this)
{
bool NewOrder = false;

// Verify, if we have order.
if (OrderID == 0)
{
// Need to create order.
OrderID = APIWrapper.OrderCreate(ServiceLocation, Algorithm, StartingAmount, StartingPrice, StartLimit, PoolData);
if (OrderID > 0)
{
NewOrder = true;
LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Created new order #" + OrderID.ToString());
}
}

if (OrderID > 0)
{
// Get all orders.
List<Order> AllOrders = APIWrapper.GetAllOrders(ServiceLocation, Algorithm);
List<Order> AllOrders = APIWrapper.GetAllOrders(ServiceLocation, Algorithm, NewOrder);
if (AllOrders != null)
{
// Find our order.
Expand Down

0 comments on commit c845e9e

Please sign in to comment.