Skip to content

Commit

Permalink
fix stopping parallel trades execution on error
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed Apr 30, 2024
1 parent 7046924 commit 57d2e64
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/HavenoClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,8 @@ async function executeTrades(ctxs: Partial<TradeContext>[], executionCtx?: Parti
if (executionCtx.concurrentTrades) {
const tradePromises: Promise<string>[] = [];
const pool = new moneroTs.ThreadPool(executionCtx.maxConcurrency!);
for (const ctx of ctxs) tradePromises.push(pool.submit(() => executeTrade(Object.assign(ctx, {concurrentTrades: executionCtx!.concurrentTrades}))));
for (let i = 0; i < ctxs.length; i++) ctxs[i] = TradeContext.init(Object.assign(ctxs[i], {concurrentTrades: executionCtx!.concurrentTrades})); // inititalize full trade contexts to avoid copy
for (const ctx of ctxs) tradePromises.push(pool.submit(() => executeTrade(ctx)));
try {
offerIds = await Promise.all(tradePromises);
} catch (e2) {
Expand Down

0 comments on commit 57d2e64

Please sign in to comment.