aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-11-23 02:15:31 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-11-24 05:13:36 +0800
commit66aaceea915b6412c8ff8bcb5001363da8aaca39 (patch)
treea636673a2fef8a6db85918e1b391fe75e3fb0a1d /packages/0x.js/src
parent4fe28ec53c4e84544c3c21853dff57c4c6a4e45d (diff)
downloaddexon-sol-tools-66aaceea915b6412c8ff8bcb5001363da8aaca39.tar
dexon-sol-tools-66aaceea915b6412c8ff8bcb5001363da8aaca39.tar.gz
dexon-sol-tools-66aaceea915b6412c8ff8bcb5001363da8aaca39.tar.bz2
dexon-sol-tools-66aaceea915b6412c8ff8bcb5001363da8aaca39.tar.lz
dexon-sol-tools-66aaceea915b6412c8ff8bcb5001363da8aaca39.tar.xz
dexon-sol-tools-66aaceea915b6412c8ff8bcb5001363da8aaca39.tar.zst
dexon-sol-tools-66aaceea915b6412c8ff8bcb5001363da8aaca39.zip
Cleanup order watcher from redundant asyncs
Diffstat (limited to 'packages/0x.js/src')
-rw-r--r--packages/0x.js/src/order_watcher/expiration_watcher.ts8
-rw-r--r--packages/0x.js/src/order_watcher/order_state_watcher.ts14
2 files changed, 11 insertions, 11 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..2ea7835d9 100644
--- a/packages/0x.js/src/order_watcher/expiration_watcher.ts
+++ b/packages/0x.js/src/order_watcher/expiration_watcher.ts
@@ -29,12 +29,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 +52,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 +70,7 @@ export class ExpirationWatcher {
const orderHash = this.orderHashByExpirationRBTree.min();
this.orderHashByExpirationRBTree.remove(orderHash);
delete this.expiration[orderHash];
- await callbackAsync(orderHash);
+ callback(orderHash);
}
}
}
diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts
index 870f42650..287172ff1 100644
--- a/packages/0x.js/src/order_watcher/order_state_watcher.ts
+++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts
@@ -94,12 +94,12 @@ export class OrderStateWatcher {
* signature is verified.
* @param signedOrder The order you wish to start watching.
*/
- public async addOrderAsync(signedOrder: SignedOrder): Promise<void> {
+ public addOrder(signedOrder: SignedOrder): void {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
assert.isValidSignature(orderHash, signedOrder.ecSignature, signedOrder.maker);
this._orderByOrderHash[orderHash] = signedOrder;
- await this.addToDependentOrderHashesAsync(signedOrder, orderHash);
+ this.addToDependentOrderHashes(signedOrder, orderHash);
const expirationUnixTimestampMs = signedOrder.expirationUnixTimestampSec.times(1000);
this._expirationWatcher.addOrder(orderHash, expirationUnixTimestampMs);
}
@@ -107,7 +107,7 @@ export class OrderStateWatcher {
* Removes an order from the orderStateWatcher
* @param orderHash The orderHash of the order you wish to stop watching.
*/
- public async removeOrderAsync(orderHash: string): Promise<void> {
+ public removeOrder(orderHash: string): void {
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
const signedOrder = this._orderByOrderHash[orderHash];
if (_.isUndefined(signedOrder)) {
@@ -134,7 +134,7 @@ export class OrderStateWatcher {
}
this._callbackIfExists = callback;
this._eventWatcher.subscribe(this._onEventWatcherCallbackAsync.bind(this));
- this._expirationWatcher.subscribe(this._onOrderExpiredAsync.bind(this));
+ this._expirationWatcher.subscribe(this._onOrderExpired.bind(this));
}
/**
* Ends an orderStateWatcher subscription.
@@ -149,14 +149,14 @@ export class OrderStateWatcher {
this._eventWatcher.unsubscribe();
this._expirationWatcher.unsubscribe();
}
- private async _onOrderExpiredAsync(orderHash: string): Promise<void> {
+ private _onOrderExpired(orderHash: string): void {
const orderState: OrderState = {
isValid: false,
orderHash,
error: ExchangeContractErrs.OrderFillExpired,
};
if (!_.isUndefined(this._orderByOrderHash[orderHash])) {
- await this.removeOrderAsync(orderHash);
+ this.removeOrder(orderHash);
if (!_.isUndefined(this._callbackIfExists)) {
this._callbackIfExists(orderState);
}
@@ -254,7 +254,7 @@ export class OrderStateWatcher {
this._callbackIfExists(orderState);
}
}
- private async addToDependentOrderHashesAsync(signedOrder: SignedOrder, orderHash: string): Promise<void> {
+ private addToDependentOrderHashes(signedOrder: SignedOrder, orderHash: string): void {
if (_.isUndefined(this._dependentOrderHashes[signedOrder.maker])) {
this._dependentOrderHashes[signedOrder.maker] = {};
}