Use Promise all while fetching events and watch contracts only once

This commit is contained in:
2021-12-28 16:08:05 +05:30
committed by nabarun
parent ba890e7d9a
commit 768a4d0818
23 changed files with 68 additions and 23 deletions
+10 -3
View File
@@ -98,12 +98,19 @@ export class GraphWatcher {
}
async addContracts () {
assert(this._indexer?.watchContract);
assert(this._indexer);
assert(this._indexer.watchContract);
assert(this._indexer.isWatchedContract);
// Watching the contract(s).
// Watching the contract(s) if not watched already.
for (const dataSource of this._dataSources) {
const { source: { address, startBlock }, name } = dataSource;
await this._indexer.watchContract(address, name, true, startBlock);
const watchedContract = await this._indexer.isWatchedContract(address);
if (!watchedContract) {
await this._indexer.watchContract(address, name, true, startBlock);
}
}
}