Refactor while condition
This commit is contained in:
@@ -54,13 +54,19 @@ export class ExpirationWatcher {
|
|||||||
}
|
}
|
||||||
private async pruneExpiredOrdersAsync(callbackAsync: (orderHash: string) => Promise<void>): Promise<void> {
|
private async pruneExpiredOrdersAsync(callbackAsync: (orderHash: string) => Promise<void>): Promise<void> {
|
||||||
const currentUnixTimestampMs = utils.getCurrentUnixTimestampMs();
|
const currentUnixTimestampMs = utils.getCurrentUnixTimestampMs();
|
||||||
while (
|
while (true) {
|
||||||
this.orderHashByExpirationRBTree.size !== 0 &&
|
const noOrdersLeft = this.orderHashByExpirationRBTree.size === 0;
|
||||||
this.expiration[this.orderHashByExpirationRBTree.min()].lessThan(
|
if (noOrdersLeft) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const nextOrderHashToExpire = this.orderHashByExpirationRBTree.min();
|
||||||
|
const noExpiredOrdersLeft = this.expiration[nextOrderHashToExpire].greaterThan(
|
||||||
currentUnixTimestampMs.plus(this.expirationMarginMs),
|
currentUnixTimestampMs.plus(this.expirationMarginMs),
|
||||||
) &&
|
);
|
||||||
!_.isUndefined(this.orderExpirationCheckingIntervalIdIfExists)
|
const noActiveSubscription = _.isUndefined(this.orderExpirationCheckingIntervalIdIfExists);
|
||||||
) {
|
if (noExpiredOrdersLeft || noActiveSubscription) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
const orderHash = this.orderHashByExpirationRBTree.min();
|
const orderHash = this.orderHashByExpirationRBTree.min();
|
||||||
this.orderHashByExpirationRBTree.remove(orderHash);
|
this.orderHashByExpirationRBTree.remove(orderHash);
|
||||||
delete this.expiration[orderHash];
|
delete this.expiration[orderHash];
|
||||||
|
|||||||
Reference in New Issue
Block a user