Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ExchangeUnion/xud into fe…
Browse files Browse the repository at this point in the history
…ature/cancelallorders
  • Loading branch information
rsercano committed Sep 29, 2020
2 parents 1624f02 + 5f3793a commit 84f0ccf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/cli/commands/removeallorders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const formatOutput = (response: RemoveAllOrdersResponse.AsObject) => {
}

if (response.removedOrderIdsList.length) {
response.removedOrderIdsList.forEach((removedOrder => console.log(`Cancelled order with id ${removedOrder}`)));
response.removedOrderIdsList.forEach((removedOrder => console.log(`Removed order with id ${removedOrder}`)));
}
if (response.onHoldOrderIdsList.length) {
response.onHoldOrderIdsList.forEach((onHoldOrder => console.log(`Failed to cancel order with id ${onHoldOrder}`)));
response.onHoldOrderIdsList.forEach((id => console.log(`Order with id ${id} has a hold for a pending swap and will be removed afterwards`)));
}

};
Expand Down
21 changes: 12 additions & 9 deletions lib/orderbook/OrderBook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -831,10 +831,10 @@ class OrderBook extends EventEmitter {
const onHoldOrderLocalIds = [];

for (const localId of this.localIdMap.keys()) {
try {
this.removeOwnOrderByLocalId(localId, true);
const onHoldIndicator = this.removeOwnOrderByLocalId(localId, true);
if (onHoldIndicator === 0) {
removedOrderLocalIds.push(localId);
} catch (ex) {
} else {
onHoldOrderLocalIds.push(localId);
}
}
Expand Down Expand Up @@ -876,12 +876,15 @@ class OrderBook extends EventEmitter {
throw errors.QUANTITY_ON_HOLD(localId, order.hold);
}

this.removeOwnOrder({
orderId: order.id,
pairId: order.pairId,
quantityToRemove: removableQuantity,
});
remainingQuantityToRemove -= removableQuantity;
if (removableQuantity > 0) {
// we can remove any portion of the order that's not on hold up front
this.removeOwnOrder({
orderId: order.id,
pairId: order.pairId,
quantityToRemove: removableQuantity,
});
remainingQuantityToRemove -= removableQuantity;
}

const failedHandler = (deal: SwapDeal) => {
if (deal.orderId === order.id) {
Expand Down

0 comments on commit 84f0ccf

Please sign in to comment.