Skip to content

Commit

Permalink
Update node core to reduce code (#330)
Browse files Browse the repository at this point in the history
* Update node core to reduce code

* Update changelog
  • Loading branch information
stwiname authored Jul 22, 2024
1 parent 8dfe090 commit 6e79304
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 202 deletions.
2 changes: 1 addition & 1 deletion packages/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed
- Enable ts strict mode
- Update to latest `@subql/node-core` (#330)

## [4.7.3] - 2024-07-16
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@nestjs/platform-express": "^9.4.0",
"@nestjs/schedule": "^3.0.1",
"@subql/common-ethereum": "workspace:*",
"@subql/node-core": "^11.0.0",
"@subql/node-core": "^12.0.0",
"@subql/testing": "^2.2.1",
"@subql/types-ethereum": "workspace:*",
"cacheable-lookup": "6",
Expand Down
13 changes: 0 additions & 13 deletions packages/node/src/admin/admin.module.ts

This file was deleted.

16 changes: 11 additions & 5 deletions packages/node/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@
import { Module } from '@nestjs/common';
import { EventEmitterModule } from '@nestjs/event-emitter';
import { ScheduleModule } from '@nestjs/schedule';
import { DbModule } from '@subql/node-core';
import { AdminModule } from './admin/admin.module';
import { DbModule, CoreModule, MetaModule } from '@subql/node-core';
import { ConfigureModule } from './configure/configure.module';
import { FetchModule } from './indexer/fetch.module';
import { MetaModule } from './meta/meta.module';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { version: ethersSdkVersion } = require('ethers/package.json');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { version: packageVersion } = require('../package.json');

@Module({
imports: [
DbModule.forRoot(),
EventEmitterModule.forRoot(),
ConfigureModule.register(),
ScheduleModule.forRoot(),
CoreModule,
FetchModule,
MetaModule,
AdminModule,
MetaModule.forRoot({
version: packageVersion,
sdkVersion: { name: 'ethers.js', version: ethersSdkVersion },
}),
],
controllers: [],
})
Expand Down
19 changes: 2 additions & 17 deletions packages/node/src/indexer/fetch.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import { Module } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import {
PoiBenchmarkService,
IndexingBenchmarkService,
StoreService,
PoiService,
ApiService,
NodeConfig,
ConnectionPoolService,
Expand All @@ -16,8 +13,8 @@ import {
IProjectUpgradeService,
PoiSyncService,
InMemoryCacheService,
SandboxService,
MonitorService,
CoreModule,
} from '@subql/node-core';
import { SubqueryProject } from '../configure/SubqueryProject';
import { EthereumApiConnection } from '../ethereum/api.connection';
Expand All @@ -35,10 +32,8 @@ import { ProjectService } from './project.service';
import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';

@Module({
imports: [CoreModule],
providers: [
InMemoryCacheService,
StoreService,
StoreCacheService,
{
provide: ApiService,
useFactory: async (
Expand All @@ -64,8 +59,6 @@ import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
],
},
IndexerManager,
ConnectionPoolStateManager,
ConnectionPoolService,
{
provide: 'IBlockDispatcher',
useFactory: (
Expand Down Expand Up @@ -132,22 +125,14 @@ import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
],
},
FetchService,
ConnectionPoolService,
IndexingBenchmarkService,
PoiBenchmarkService,
EthDictionaryService,
SandboxService,
DsProcessorService,
DynamicDsService,
PoiService,
PoiSyncService,
{
useClass: ProjectService,
provide: 'IProjectService',
},
MonitorService,
UnfinalizedBlocksService,
],
exports: [StoreService, StoreCacheService, MonitorService, PoiService],
})
export class FetchModule {}
3 changes: 3 additions & 0 deletions packages/node/src/indexer/fetch.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
getModulos,
getLogger,
Header,
StoreCacheService,
} from '@subql/node-core';
import { EthereumBlock, SubqlDatasource } from '@subql/types-ethereum';
import { SubqueryProject } from '../configure/SubqueryProject';
Expand Down Expand Up @@ -47,6 +48,7 @@ export class FetchService extends BaseFetchService<
unfinalizedBlocksService: UnfinalizedBlocksService,
eventEmitter: EventEmitter2,
schedulerRegistry: SchedulerRegistry,
storeCacheService: StoreCacheService,
) {
super(
nodeConfig,
Expand All @@ -57,6 +59,7 @@ export class FetchService extends BaseFetchService<
eventEmitter,
schedulerRegistry,
unfinalizedBlocksService,
storeCacheService,
);
}

Expand Down
24 changes: 2 additions & 22 deletions packages/node/src/indexer/worker/worker-fetch.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ import {
ApiService,
ConnectionPoolService,
WorkerDynamicDsService,
WorkerConnectionPoolStateManager,
ConnectionPoolStateManager,
NodeConfig,
InMemoryCacheService,
WorkerInMemoryCacheService,
WorkerUnfinalizedBlocksService,
SandboxService,
MonitorService,
WorkerMonitorService,
WorkerCoreModule,
} from '@subql/node-core';
import { SubqueryProject } from '../../configure/SubqueryProject';
import { EthereumApiService } from '../../ethereum';
Expand All @@ -28,14 +22,9 @@ import { UnfinalizedBlocksService } from '../unfinalizedBlocks.service';
import { WorkerService } from './worker.service';

@Module({
imports: [WorkerCoreModule],
providers: [
IndexerManager,
{
provide: ConnectionPoolStateManager,
useFactory: () =>
new WorkerConnectionPoolStateManager((global as any).host),
},
ConnectionPoolService,
{
provide: ApiService,
useFactory: async (
Expand All @@ -60,7 +49,6 @@ import { WorkerService } from './worker.service';
NodeConfig,
],
},
SandboxService,
DsProcessorService,
{
provide: DynamicDsService,
Expand All @@ -76,14 +64,6 @@ import { WorkerService } from './worker.service';
new WorkerUnfinalizedBlocksService((global as any).host),
},
WorkerService,
{
provide: MonitorService,
useFactory: () => new WorkerMonitorService((global as any).host),
},
{
provide: InMemoryCacheService,
useFactory: () => new WorkerInMemoryCacheService((global as any).host),
},
],
})
export class WorkerFetchModule {}
3 changes: 2 additions & 1 deletion packages/node/src/indexer/worker/worker.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { Module } from '@nestjs/common';
import { EventEmitterModule } from '@nestjs/event-emitter';
import { ScheduleModule } from '@nestjs/schedule';
import { DbModule } from '@subql/node-core';
import { DbModule, WorkerCoreModule } from '@subql/node-core';
import { ConfigureModule } from '../../configure/configure.module';
import { WorkerFetchModule } from './worker-fetch.module';

Expand All @@ -14,6 +14,7 @@ import { WorkerFetchModule } from './worker-fetch.module';
EventEmitterModule.forRoot(),
ConfigureModule.register(),
ScheduleModule.forRoot(),
WorkerCoreModule,
WorkerFetchModule,
],
controllers: [],
Expand Down
15 changes: 0 additions & 15 deletions packages/node/src/meta/meta.controller.ts

This file was deleted.

16 changes: 0 additions & 16 deletions packages/node/src/meta/meta.module.ts

This file was deleted.

101 changes: 0 additions & 101 deletions packages/node/src/meta/meta.service.ts

This file was deleted.

Loading

0 comments on commit 6e79304

Please sign in to comment.