-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add factory for creating block dispatcher (#2701)
* Add factory for creating block dispatcher * Update changelog * Update changelog
- Loading branch information
Showing
6 changed files
with
124 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
import {EventEmitter2} from '@nestjs/event-emitter'; | ||
import {BaseDataSource} from '@subql/types-core'; | ||
import {IApiConnectionSpecific} from '../../api.service'; | ||
import {IBlockchainService} from '../../blockchain.service'; | ||
import {IProjectUpgradeService, NodeConfig} from '../../configure'; | ||
import {ConnectionPoolStateManager} from '../connectionPoolState.manager'; | ||
import {DynamicDsService} from '../dynamic-ds.service'; | ||
import {InMemoryCacheService} from '../inMemoryCache.service'; | ||
import {MonitorService} from '../monitor.service'; | ||
import {PoiSyncService} from '../poi'; | ||
import {ProjectService} from '../project.service'; | ||
import {StoreService} from '../store.service'; | ||
import {IStoreModelProvider} from '../storeModelProvider'; | ||
import {IIndexerManager, ISubqueryProject} from '../types'; | ||
import {UnfinalizedBlocksService} from '../unfinalizedBlocks.service'; | ||
import {createIndexerWorker, IBaseIndexerWorker} from '../worker'; | ||
import {IBlockDispatcher} from './base-block-dispatcher'; | ||
import {BlockDispatcher} from './block-dispatcher'; | ||
import {WorkerBlockDispatcher} from './worker-block-dispatcher'; | ||
|
||
export const blockDispatcherFactory = | ||
<DS extends BaseDataSource, Block, ApiConn extends IApiConnectionSpecific, Worker extends IBaseIndexerWorker>( | ||
workerPath: string, | ||
workerFns: Parameters<typeof createIndexerWorker<Worker, ApiConn, Block, DS>>[1] | ||
) => | ||
( | ||
nodeConfig: NodeConfig, | ||
eventEmitter: EventEmitter2, | ||
projectService: ProjectService<DS>, | ||
projectUpgradeService: IProjectUpgradeService, | ||
cacheService: InMemoryCacheService, | ||
storeService: StoreService, | ||
storeModelProvider: IStoreModelProvider, | ||
poiSyncService: PoiSyncService, | ||
project: ISubqueryProject, | ||
dynamicDsService: DynamicDsService<DS>, | ||
unfinalizedBlocks: UnfinalizedBlocksService, | ||
connectionPoolState: ConnectionPoolStateManager<ApiConn>, | ||
blockchainService: IBlockchainService<DS>, | ||
indexerManager: IIndexerManager<Block, DS>, | ||
monitorService?: MonitorService | ||
): IBlockDispatcher<Block> => { | ||
return nodeConfig.workers | ||
? new WorkerBlockDispatcher<DS, Worker, Block, ApiConn>( | ||
nodeConfig, | ||
eventEmitter, | ||
projectService, | ||
projectUpgradeService, | ||
storeService, | ||
storeModelProvider, | ||
cacheService, | ||
poiSyncService, | ||
dynamicDsService, | ||
unfinalizedBlocks, | ||
connectionPoolState, | ||
project, | ||
blockchainService, | ||
workerPath, | ||
workerFns, | ||
monitorService | ||
) | ||
: new BlockDispatcher( | ||
nodeConfig, | ||
eventEmitter, | ||
projectService, | ||
projectUpgradeService, | ||
storeService, | ||
storeModelProvider, | ||
poiSyncService, | ||
project, | ||
blockchainService, | ||
indexerManager | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters