From 03f2d03688b9e57c7cbe0b02211344373d71d1d8 Mon Sep 17 00:00:00 2001 From: xianny Date: Wed, 19 Feb 2020 12:15:53 -0800 Subject: [PATCH] use chunking when adding orders to mesh --- src/services/orderbook_service.ts | 2 +- src/utils/mesh_utils.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/orderbook_service.ts b/src/services/orderbook_service.ts index 25961c12fe..58cea3ada0 100644 --- a/src/services/orderbook_service.ts +++ b/src/services/orderbook_service.ts @@ -182,7 +182,7 @@ export class OrderBookService { } public async addOrdersAsync(signedOrders: SignedOrder[]): Promise { if (this._meshClient) { - const { rejected } = await this._meshClient.addOrdersAsync(signedOrders as any); + const { rejected } = await meshUtils.addOrdersToMeshAsync(this._meshClient, signedOrders); if (rejected.length !== 0) { const validationErrors = rejected.map((r, i) => ({ field: `signedOrder[${i}]`, diff --git a/src/utils/mesh_utils.ts b/src/utils/mesh_utils.ts index b2e7be391e..fb6a38913a 100644 --- a/src/utils/mesh_utils.ts +++ b/src/utils/mesh_utils.ts @@ -20,14 +20,14 @@ export const meshUtils = { addOrdersToMeshAsync: async ( meshClient: WSClient, orders: SignedOrder[], - batchSize: number = 100, + batchSize: number = 200, ): Promise => { // Mesh rpc client can't handle a large amount of orders. This results in a fragmented // send which Mesh cannot accept. const validationResults: ValidationResults = { accepted: [], rejected: [] }; const chunks = _.chunk(orders, batchSize); for (const chunk of chunks) { - const results = await meshClient.addOrdersAsync(chunk as any); + const results = await meshClient.addOrdersAsync(chunk); validationResults.accepted = [...validationResults.accepted, ...results.accepted]; validationResults.rejected = [...validationResults.rejected, ...results.rejected]; }