diff options
-rw-r--r-- | src/order_watcher/order_state_watcher.ts | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/order_watcher/order_state_watcher.ts b/src/order_watcher/order_state_watcher.ts index f7e3a38a0..f06e32a32 100644 --- a/src/order_watcher/order_state_watcher.ts +++ b/src/order_watcher/order_state_watcher.ts @@ -87,8 +87,7 @@ export class OrderStateWatcher { return; // noop } delete this._orderByOrderHash[orderHash]; - this._dependentOrderHashes[signedOrder.maker][signedOrder.makerTokenAddress].delete(orderHash); - // We currently do not remove the maker/makerToken keys from the mapping when all orderHashes removed + this.removeFromDependentOrderHashes(signedOrder.maker, signedOrder.makerTokenAddress, orderHash); } /** * Starts an orderStateWatcher subscription. The callback will be called every time a watched order's @@ -191,4 +190,13 @@ export class OrderStateWatcher { } this._dependentOrderHashes[signedOrder.maker][signedOrder.makerTokenAddress].add(orderHash); } + private removeFromDependentOrderHashes(makerAddress: string, makerTokenAddress: string, orderHash: string) { + this._dependentOrderHashes[makerAddress][makerTokenAddress].delete(orderHash); + if (this._dependentOrderHashes[makerAddress][makerTokenAddress].size === 0) { + delete this._dependentOrderHashes[makerAddress][makerTokenAddress]; + } + if (_.isEmpty(this._dependentOrderHashes[makerAddress])) { + delete this._dependentOrderHashes[makerAddress]; + } + } } |