Skip to content

Commit c845e9e

Browse files
author
nicehashdev
committed
Bug fix
Fixed bug that was generating infinite number of orders.
1 parent cb43811 commit c845e9e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/NiceHashBotLib/APIWrapper.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,13 @@ public static APIBalance GetBalance()
144144
/// </summary>
145145
/// <param name="ServiceLocation">Service location; 0 for NiceHash, 1 for WestHash.</param>
146146
/// <param name="Algorithm">Algorithm number.</param>
147+
/// <param name="ForceReCache">Set this to true to recache order list.</param>
147148
/// <returns>Array list of orders.</returns>
148-
public static List<Order> GetAllOrders(int ServiceLocation, int Algorithm)
149+
public static List<Order> GetAllOrders(int ServiceLocation, int Algorithm, bool ForceReCache)
149150
{
150151
lock (CacheLock)
151152
{
152-
if (CachedOList[ServiceLocation, Algorithm] == null || (CachedOList[ServiceLocation, Algorithm].ObtainTime + TimeSpan.FromSeconds(29.0) < DateTime.Now))
153+
if (ForceReCache || CachedOList[ServiceLocation, Algorithm] == null || (CachedOList[ServiceLocation, Algorithm].ObtainTime + TimeSpan.FromSeconds(29.0) < DateTime.Now))
153154
{
154155
CachedOList[ServiceLocation, Algorithm] = new CachedOrderList();
155156
CachedOList[ServiceLocation, Algorithm].OrderList = GetOrders(ServiceLocation, Algorithm, "orders.get", false);

src/NiceHashBotLib/OrderInstance.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,24 @@ private void ThreadRun()
123123

124124
lock (this)
125125
{
126+
bool NewOrder = false;
127+
126128
// Verify, if we have order.
127129
if (OrderID == 0)
128130
{
129131
// Need to create order.
130132
OrderID = APIWrapper.OrderCreate(ServiceLocation, Algorithm, StartingAmount, StartingPrice, StartLimit, PoolData);
131133
if (OrderID > 0)
134+
{
135+
NewOrder = true;
132136
LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Created new order #" + OrderID.ToString());
137+
}
133138
}
134139

135140
if (OrderID > 0)
136141
{
137142
// Get all orders.
138-
List<Order> AllOrders = APIWrapper.GetAllOrders(ServiceLocation, Algorithm);
143+
List<Order> AllOrders = APIWrapper.GetAllOrders(ServiceLocation, Algorithm, NewOrder);
139144
if (AllOrders != null)
140145
{
141146
// Find our order.

0 commit comments

Comments
 (0)