Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
Dont process jobs multiple times if the event status is Processed alr…
Browse files Browse the repository at this point in the history
…eady

related to #594
  • Loading branch information
mohammadranjbarz committed Aug 25, 2021
1 parent 43e0ec8 commit 8cd0dca
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/blockchain/lib/eventHandlerQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ const initEventHandlerQueue = app => {
logIndex: event.logIndex,
_id: event._id,
});
const eventInDb = await eventService.get(event._id);
if (eventInDb === EventStatus.PROCESSED) {
logger.info('Event is already processed, so dont need to handle again', {
event: event.event,
_id: event._id,
transactionHash: event.transactionHash,
transactionIndex: event.transactionIndex,
});
clearTimeout(callDoneTimeout);
done();
return;
}
if (typeof handler === 'function') {
await handler(event);
} else {
Expand Down

0 comments on commit 8cd0dca

Please sign in to comment.