Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix IStoreModelProvider inject #2603

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions packages/node-core/src/indexer/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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,
Expand Down
16 changes: 16 additions & 0 deletions packages/node-core/src/indexer/storeModelProvider/utils.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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);
}
3 changes: 3 additions & 0 deletions packages/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions packages/node/src/subcommands/reindex.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions packages/node/src/subcommands/testing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down
Loading