Skip to content

Commit

Permalink
refactor: pin claims in promise.all
Browse files Browse the repository at this point in the history
  • Loading branch information
JGiter committed Jul 31, 2023
1 parent 40015bd commit f9a5f13
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/modules/did/did.processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ export class DIDProcessor {
public async processDIDDocumentAddition(job: Job<string>) {
const doc = await this.didService.addCachedDocument(job.data);

for (const cid of doc.service.map((s) => s.serviceEndpoint)) {
await this.pinQueue.add(PIN_CLAIM_JOB_NAME, { cid });
}
await Promise.all(
doc.service.map(({ serviceEndpoint }) => {
this.pinQueue.add(PIN_CLAIM_JOB_NAME, {
cid: serviceEndpoint,
});
})
);
}

@Process(UPDATE_DID_DOC_JOB_NAME)
Expand All @@ -69,10 +73,12 @@ export class DIDProcessor {
doc = await this.didService.incrementalRefreshCachedDocument(job.data);
}

for (const service of doc.service) {
await this.pinQueue.add(PIN_CLAIM_JOB_NAME, {
cid: service.serviceEndpoint,
});
}
await Promise.all(
doc.service.map(({ serviceEndpoint }) => {
this.pinQueue.add(PIN_CLAIM_JOB_NAME, {
cid: serviceEndpoint,
});
})
);
}
}

0 comments on commit f9a5f13

Please sign in to comment.