Fix redundant expired order removal bug

This commit is contained in:
Ara Kevonian
2018-04-17 07:25:13 -07:00
parent bf4873e519
commit cbca2061f7

View File

@@ -123,7 +123,7 @@ export class OrderStateWatcher {
* Removes an order from the orderStateWatcher
* @param orderHash The orderHash of the order you wish to stop watching.
*/
public removeOrder(orderHash: string): void {
public removeOrder(orderHash: string, removeFromExpirationWatcher: boolean = true): void {
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
const signedOrder = this._orderByOrderHash[orderHash];
if (_.isUndefined(signedOrder)) {
@@ -139,7 +139,9 @@ export class OrderStateWatcher {
this._removeFromDependentOrderHashes(signedOrder.maker, signedOrder.makerTokenAddress, orderHash);
}
this._expirationWatcher.removeOrder(orderHash);
if (removeFromExpirationWatcher) {
this._expirationWatcher.removeOrder(orderHash);
}
}
/**
* Starts an orderStateWatcher subscription. The callback will be called every time a watched order's
@@ -212,7 +214,7 @@ export class OrderStateWatcher {
error: ExchangeContractErrs.OrderFillExpired,
};
if (!_.isUndefined(this._orderByOrderHash[orderHash])) {
this.removeOrder(orderHash);
this.removeOrder(orderHash, false);
if (!_.isUndefined(this._callbackIfExists)) {
this._callbackIfExists(null, orderState);
}