Skip to content

Commit

Permalink
Fix indexing events multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
stwiname committed Oct 30, 2023
1 parent 98ab171 commit 4553638
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/node/src/indexer/indexer.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ export class IndexerManager extends BaseIndexerManager<
for (const msg of msgs) {
await this.indexMessage(msg, dataSources, getVM);
const events = blockContent.events.filter(
(event) => event.msg?.idx === msg.idx,
(event) => event.tx.hash === tx.hash && event.msg?.idx === msg.idx,
);

for (const evt of events) {
await this.indexEvent(evt, dataSources, getVM);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/node/src/subcommands/testing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
ConnectionPoolService,
ConnectionPoolStateManager,
DbModule,
InMemoryCacheService,
PoiService,
PoiSyncService,
StoreService,
TestRunner,
} from '@subql/node-core';
Expand All @@ -26,10 +28,12 @@ import { UnfinalizedBlocksService } from '../indexer/unfinalizedBlocks.service';

@Module({
providers: [
InMemoryCacheService,
StoreService,
StoreCacheService,
EventEmitter2,
PoiService,
PoiSyncService,
SandboxService,
DsProcessorService,
DynamicDsService,
Expand Down
3 changes: 3 additions & 0 deletions packages/types/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export interface CosmosTransaction {
}

export interface CosmosMessage<T = any> {
/**
* The index of the message within the transaction
*/
idx: number;
block: CosmosBlock;
tx: CosmosTransaction;
Expand Down

0 comments on commit 4553638

Please sign in to comment.