Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Clarify parallelization of orderbook & RFQT
Browse files Browse the repository at this point in the history
Addresses review comment #2541 (comment)
  • Loading branch information
feuGeneA committed Apr 11, 2020
1 parent 8f94b52 commit 2967799
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/asset-swapper/src/swap_quoter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,9 @@ export class SwapQuoter {
} else {
gasPrice = await this._protocolFeeUtils.getGasPriceEstimationOrThrowAsync();
}
// get the relevant orders for the makerAsset
const orderPromises: Array<Promise<SignedOrder[]>> = [
this._getSignedOrdersAsync(makerAssetData, takerAssetData),
];
// get batches of orders from different sources, awaiting sources in parallel
const orderBatchPromises: Array<Promise<SignedOrder[]>> = [];
orderBatchPromises.push(this._getSignedOrdersAsync(makerAssetData, takerAssetData)); // order book
if (
options.rfqt &&
options.rfqt.intentOnFilling &&
Expand All @@ -541,7 +540,7 @@ export class SwapQuoter {
if (!options.rfqt.takerAddress || options.rfqt.takerAddress === constants.NULL_ADDRESS) {
throw new Error('RFQ-T requests must specify a taker address');
}
orderPromises.push(
orderBatchPromises.push(
this._quoteRequestor.requestRfqtFirmQuotesAsync(
makerAssetData,
takerAssetData,
Expand All @@ -552,7 +551,8 @@ export class SwapQuoter {
),
);
}
const orders: SignedOrder[] = ([] as SignedOrder[]).concat(...(await Promise.all(orderPromises)));
const orderBatches: SignedOrder[][] = await Promise.all(orderBatchPromises);
const orders: SignedOrder[] = orderBatches.reduce((_orders, batch) => _orders.concat(...batch));
// if no native orders, pass in a dummy order for the sampler to have required metadata for sampling
if (orders.length === 0) {
orders.push(
Expand Down

0 comments on commit 2967799

Please sign in to comment.