diff --git a/packages/node-core/src/indexer/core.module.ts b/packages/node-core/src/indexer/core.module.ts index 1f4cb87c3f..f5a3cbcb29 100644 --- a/packages/node-core/src/indexer/core.module.ts +++ b/packages/node-core/src/indexer/core.module.ts @@ -15,7 +15,7 @@ import {MonitorService} from './monitor.service'; import {PoiService, PoiSyncService} from './poi'; import {SandboxService} from './sandbox.service'; import {StoreService} from './store.service'; -import {IStoreModelProvider, PlainStoreModelService, StoreCacheService} from './storeModelProvider'; +import {storeModelFactory} from './storeModelProvider'; @Module({ providers: [ @@ -31,16 +31,7 @@ import {IStoreModelProvider, PlainStoreModelService, StoreCacheService} from './ StoreService, { provide: 'IStoreModelProvider', - useFactory: ( - nodeConfig: NodeConfig, - eventEmitter: EventEmitter2, - schedulerRegistry: SchedulerRegistry, - sequelize: Sequelize - ): IStoreModelProvider => { - return nodeConfig.enableCache - ? new StoreCacheService(sequelize, nodeConfig, eventEmitter, schedulerRegistry) - : new PlainStoreModelService(sequelize, nodeConfig); - }, + useFactory: storeModelFactory, inject: [NodeConfig, EventEmitter2, SchedulerRegistry, Sequelize], }, AdminListener, diff --git a/packages/node-core/src/indexer/storeModelProvider/utils.ts b/packages/node-core/src/indexer/storeModelProvider/utils.ts index 0ca72be4cb..8e8782b251 100644 --- a/packages/node-core/src/indexer/storeModelProvider/utils.ts +++ b/packages/node-core/src/indexer/storeModelProvider/utils.ts @@ -1,7 +1,12 @@ // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors // SPDX-License-Identifier: GPL-3.0 +import {EventEmitter2} from '@nestjs/event-emitter'; +import {SchedulerRegistry} from '@nestjs/schedule'; +import {NodeConfig} from '@subql/node-core/configure'; +import {Sequelize} from '@subql/x-sequelize'; import {StoreCacheService} from './storeCache.service'; +import {PlainStoreModelService} from './storeModel.service'; import {IStoreModelProvider} from './types'; export async function cacheProviderFlushData(modelProvider: IStoreModelProvider, forceFlush?: boolean) { @@ -14,3 +19,14 @@ export async function cacheProviderResetData(modelProvider: IStoreModelProvider) await modelProvider.resetData(); } } + +export function storeModelFactory( + nodeConfig: NodeConfig, + eventEmitter: EventEmitter2, + schedulerRegistry: SchedulerRegistry, + sequelize: Sequelize +): IStoreModelProvider { + return nodeConfig.enableCache + ? new StoreCacheService(sequelize, nodeConfig, eventEmitter, schedulerRegistry) + : new PlainStoreModelService(sequelize, nodeConfig); +} diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index 593c2076bf..c5cdcdc503 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Fix part of the module.ts file that is missing the logic for injecting `IStoreModelProvider`. + ## [5.3.0] - 2024-11-22 ### Added - Support for historical indexing by timestamp as well as block height (#2584) diff --git a/packages/node/src/subcommands/reindex.module.ts b/packages/node/src/subcommands/reindex.module.ts index 965bfef559..6f45c5ad19 100644 --- a/packages/node/src/subcommands/reindex.module.ts +++ b/packages/node/src/subcommands/reindex.module.ts @@ -7,14 +7,15 @@ import { SchedulerRegistry } from '@nestjs/schedule'; import { DbModule, ForceCleanService, - StoreCacheService, ReindexService, StoreService, PoiService, ConnectionPoolService, NodeConfig, ConnectionPoolStateManager, + storeModelFactory, } from '@subql/node-core'; +import { Sequelize } from '@subql/x-sequelize'; import { ConfigureModule } from '../configure/configure.module'; import { ApiService } from '../indexer/api.service'; import { DsProcessorService } from '../indexer/ds-processor.service'; @@ -23,7 +24,11 @@ import { UnfinalizedBlocksService } from '../indexer/unfinalizedBlocks.service'; @Module({ providers: [ - StoreCacheService, + { + provide: 'IStoreModelProvider', + useFactory: storeModelFactory, + inject: [NodeConfig, EventEmitter2, SchedulerRegistry, Sequelize], + }, StoreService, ReindexService, PoiService, diff --git a/packages/node/src/subcommands/testing.module.ts b/packages/node/src/subcommands/testing.module.ts index 0f6d806e35..bbaa0c079f 100644 --- a/packages/node/src/subcommands/testing.module.ts +++ b/packages/node/src/subcommands/testing.module.ts @@ -11,12 +11,13 @@ import { InMemoryCacheService, PoiService, PoiSyncService, - StoreCacheService, StoreService, TestRunner, SandboxService, NodeConfig, + storeModelFactory, } from '@subql/node-core'; +import { Sequelize } from '@subql/x-sequelize'; import { ConfigureModule } from '../configure/configure.module'; import { ApiService } from '../indexer/api.service'; import { DsProcessorService } from '../indexer/ds-processor.service'; @@ -29,7 +30,11 @@ import { UnfinalizedBlocksService } from '../indexer/unfinalizedBlocks.service'; providers: [ InMemoryCacheService, StoreService, - StoreCacheService, + { + provide: 'IStoreModelProvider', + useFactory: storeModelFactory, + inject: [NodeConfig, EventEmitter2, SchedulerRegistry, Sequelize], + }, EventEmitter2, PoiService, PoiSyncService,