mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
multithread search by dt address (#559)
Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
This commit is contained in:
parent
d1b28a9e15
commit
316c3f5010
@ -7,6 +7,8 @@ import Web3 from 'web3'
|
|||||||
import { SubscribablePromise, Logger, getFairGasPrice } from '../utils'
|
import { SubscribablePromise, Logger, getFairGasPrice } from '../utils'
|
||||||
import { DataTokens } from '../datatokens/Datatokens'
|
import { DataTokens } from '../datatokens/Datatokens'
|
||||||
|
|
||||||
|
const MAX_AWAIT_PROMISES = 10
|
||||||
|
|
||||||
export interface FixedPriceExchange {
|
export interface FixedPriceExchange {
|
||||||
exchangeID?: string
|
exchangeID?: string
|
||||||
exchangeOwner: string
|
exchangeOwner: string
|
||||||
@ -366,8 +368,13 @@ export class OceanFixedRateExchange {
|
|||||||
fromBlock: this.startBlock,
|
fromBlock: this.startBlock,
|
||||||
toBlock: 'latest'
|
toBlock: 'latest'
|
||||||
})
|
})
|
||||||
|
let promises = []
|
||||||
for (let i = 0; i < events.length; i++) {
|
for (let i = 0; i < events.length; i++) {
|
||||||
const constituents = await this.getExchange(events[i].returnValues[0])
|
promises.push(this.getExchange(events[i].returnValues[0]))
|
||||||
|
if (promises.length > MAX_AWAIT_PROMISES || i === events.length - 1) {
|
||||||
|
const results = await Promise.all(promises)
|
||||||
|
for (let j = 0; j < results.length; j++) {
|
||||||
|
const constituents = results[j]
|
||||||
constituents.exchangeID = events[i].returnValues[0]
|
constituents.exchangeID = events[i].returnValues[0]
|
||||||
if (
|
if (
|
||||||
constituents.active === true &&
|
constituents.active === true &&
|
||||||
@ -380,6 +387,9 @@ export class OceanFixedRateExchange {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
promises = []
|
||||||
|
}
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user