diff options
Diffstat (limited to 'packages/0x.js/src/order_watcher/expiration_watcher.ts')
-rw-r--r-- | packages/0x.js/src/order_watcher/expiration_watcher.ts | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/packages/0x.js/src/order_watcher/expiration_watcher.ts b/packages/0x.js/src/order_watcher/expiration_watcher.ts index 717edaad7..9a1bb1ca4 100644 --- a/packages/0x.js/src/order_watcher/expiration_watcher.ts +++ b/packages/0x.js/src/order_watcher/expiration_watcher.ts @@ -1,10 +1,11 @@ -import * as _ from 'lodash'; import {BigNumber} from 'bignumber.js'; import {RBTree} from 'bintrees'; -import {utils} from '../utils/utils'; -import {intervalUtils} from '../utils/interval_utils'; -import {SignedOrder, ZeroExError} from '../types'; +import * as _ from 'lodash'; + import {ZeroEx} from '../0x'; +import {SignedOrder, ZeroExError} from '../types'; +import {intervalUtils} from '../utils/interval_utils'; +import {utils} from '../utils/utils'; const DEFAULT_EXPIRATION_MARGIN_MS = 0; const DEFAULT_ORDER_EXPIRATION_CHECKING_INTERVAL_MS = 50; @@ -29,12 +30,12 @@ export class ExpirationWatcher { const comparator = (lhs: string, rhs: string) => scoreFunction(lhs) - scoreFunction(rhs); this.orderHashByExpirationRBTree = new RBTree(comparator); } - public subscribe(callbackAsync: (orderHash: string) => Promise<void>): void { + public subscribe(callback: (orderHash: string) => void): void { if (!_.isUndefined(this.orderExpirationCheckingIntervalIdIfExists)) { throw new Error(ZeroExError.SubscriptionAlreadyPresent); } this.orderExpirationCheckingIntervalIdIfExists = intervalUtils.setAsyncExcludingInterval( - this.pruneExpiredOrdersAsync.bind(this, callbackAsync), this.orderExpirationCheckingIntervalMs, + this.pruneExpiredOrders.bind(this, callback), this.orderExpirationCheckingIntervalMs, ); } public unsubscribe(): void { @@ -52,7 +53,7 @@ export class ExpirationWatcher { this.orderHashByExpirationRBTree.remove(orderHash); delete this.expiration[orderHash]; } - private async pruneExpiredOrdersAsync(callbackAsync: (orderHash: string) => Promise<void>): Promise<void> { + private pruneExpiredOrders(callback: (orderHash: string) => void): void { const currentUnixTimestampMs = utils.getCurrentUnixTimestampMs(); while (true) { const hasTrakedOrders = this.orderHashByExpirationRBTree.size === 0; @@ -70,7 +71,7 @@ export class ExpirationWatcher { const orderHash = this.orderHashByExpirationRBTree.min(); this.orderHashByExpirationRBTree.remove(orderHash); delete this.expiration[orderHash]; - await callbackAsync(orderHash); + callback(orderHash); } } } |