Skip to content

Commit

Permalink
ignore old events in ContractEventsEmitter
Browse files Browse the repository at this point in the history
  • Loading branch information
defi-dev committed Feb 20, 2024
1 parent 8859e31 commit dfd3fe0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/services/ContractEventsEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export default class ContractEventsEmitter {
contractEmitterCount = {};
emitByBlockCount = {};

lastBlockNumber = null;

constructor(_blockLogsMode) {
this.setBlockLogsMode(_blockLogsMode);
}
Expand All @@ -22,7 +24,10 @@ export default class ContractEventsEmitter {
}

emitByContractAddress(address, eventName, value) {
this.contractEmitterByAddress[address].emit(eventName, value);
if (!this.lastBlockNumber || value.blockNumber >= this.lastBlockNumber) {
this.contractEmitterByAddress[address].emit(eventName, value);
this.lastBlockNumber = value.blockNumber;
}
}

emitByBlockLogs(logs, forceEmit = false) {
Expand Down

0 comments on commit dfd3fe0

Please sign in to comment.