Commit 793afebe authored by Pavel Ševčík's avatar Pavel Ševčík Committed by Pavel Ševčík
Browse files

Make indexer calls more efficient

parent 1f465db7
......@@ -93,25 +93,37 @@ class RpcClient {
/**
* Send multiple requests (batch mode)
* @param {Object[]} batch - array of objects {method: ..., params: ...}
* @return {Promise}
* @return {Promise<object[]>}
*/
async sendBatch(batch) {
return this._call(batch, true)
const batchList = util.splitList(batch, 100)
const responses = await util.seriesCall(batchList, (requests) => {
return this._call(requests, true)
})
return responses.flat()
}
/**
* Send multiple requests (flood mode)
* @param {Object[]} batch - array of objects {method: ..., params: ...}
* @return {Promise}
* @return {Promise<object[]>}
*/
async sendRequests(batch) {
return this._call(batch, false)
const batchList = util.splitList(batch, 100)
const responses = await util.seriesCall(batchList, (requests) => {
return this._call(requests, false)
})
return responses.flat()
}
/**
* Send a request
* @param {string} method - called method
* @return {Promise}
* @return {Promise<object>}
*/
async sendRequest(method, ...params) {
const batch = [{method: method, params: params}]
......@@ -123,7 +135,7 @@ class RpcClient {
* Send requests (internal method)
* @param {Object[]} data - array of objects {method: ..., params: ...}
* @param {boolean=} batched - batch requests
* @returns {Promise}
* @returns {Promise<object[]>}
*/
async _call(data, batched) {
return new Promise((resolve, reject) => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment