@subql/node-ethereum 0.4.1-13 → 0.4.1-15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/app.module.js.map +1 -1
- package/dist/configure/SubqueryProject.d.ts +1 -1
- package/dist/configure/SubqueryProject.js +3 -0
- package/dist/configure/SubqueryProject.js.map +1 -1
- package/dist/configure/configure.module.js +2 -2
- package/dist/configure/configure.module.js.map +1 -1
- package/dist/ethereum/api.connection.d.ts +11 -0
- package/dist/ethereum/api.connection.js +27 -0
- package/dist/ethereum/api.connection.js.map +1 -0
- package/dist/ethereum/api.ethereum.d.ts +2 -0
- package/dist/ethereum/api.ethereum.js +37 -19
- package/dist/ethereum/api.ethereum.js.map +1 -1
- package/dist/ethereum/api.service.ethereum.d.ts +5 -4
- package/dist/ethereum/api.service.ethereum.js +49 -18
- package/dist/ethereum/api.service.ethereum.js.map +1 -1
- package/dist/ethereum/ethers/json-rpc-batch-provider.js +8 -3
- package/dist/ethereum/ethers/json-rpc-batch-provider.js.map +1 -1
- package/dist/ethereum/ethers/web/index.d.ts +0 -1
- package/dist/ethereum/ethers/web/types.d.ts +0 -1
- package/dist/ethereum/utils.ethereum.js +7 -5
- package/dist/ethereum/utils.ethereum.js.map +1 -1
- package/dist/indexer/blockDispatcher/block-dispatcher.service.d.ts +8 -15
- package/dist/indexer/blockDispatcher/block-dispatcher.service.js +20 -112
- package/dist/indexer/blockDispatcher/block-dispatcher.service.js.map +1 -1
- package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.d.ts +4 -0
- package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.js +5 -0
- package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.js.map +1 -0
- package/dist/indexer/blockDispatcher/index.d.ts +2 -2
- package/dist/indexer/blockDispatcher/index.js.map +1 -1
- package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.d.ts +12 -17
- package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js +48 -141
- package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js.map +1 -1
- package/dist/indexer/dictionary.service.js.map +1 -1
- package/dist/indexer/ds-processor.service.js.map +1 -1
- package/dist/indexer/dynamic-ds.service.d.ts +3 -22
- package/dist/indexer/dynamic-ds.service.js +4 -91
- package/dist/indexer/dynamic-ds.service.js.map +1 -1
- package/dist/indexer/fetch.module.js +35 -9
- package/dist/indexer/fetch.module.js.map +1 -1
- package/dist/indexer/fetch.service.d.ts +4 -4
- package/dist/indexer/fetch.service.js +42 -45
- package/dist/indexer/fetch.service.js.map +1 -1
- package/dist/indexer/indexer.manager.d.ts +3 -14
- package/dist/indexer/indexer.manager.js +17 -59
- package/dist/indexer/indexer.manager.js.map +1 -1
- package/dist/indexer/indexer.module.js +29 -5
- package/dist/indexer/indexer.module.js.map +1 -1
- package/dist/indexer/project.service.d.ts +4 -10
- package/dist/indexer/project.service.js +42 -102
- package/dist/indexer/project.service.js.map +1 -1
- package/dist/indexer/sandbox.service.js +6 -1
- package/dist/indexer/sandbox.service.js.map +1 -1
- package/dist/indexer/unfinalizedBlocks.service.d.ts +12 -12
- package/dist/indexer/unfinalizedBlocks.service.js +32 -38
- package/dist/indexer/unfinalizedBlocks.service.js.map +1 -1
- package/dist/indexer/unfinalizedBlocks.spec.js +41 -34
- package/dist/indexer/unfinalizedBlocks.spec.js.map +1 -1
- package/dist/indexer/worker/worker.d.ts +22 -8
- package/dist/indexer/worker/worker.js +14 -7
- package/dist/indexer/worker/worker.js.map +1 -1
- package/dist/indexer/worker/worker.module.js.map +1 -1
- package/dist/indexer/worker/worker.service.d.ts +2 -2
- package/dist/indexer/worker/worker.service.js +12 -5
- package/dist/indexer/worker/worker.service.js.map +1 -1
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.d.ts +11 -0
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.js +32 -0
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.js.map +1 -0
- package/dist/init.js +2 -2
- package/dist/init.js.map +1 -1
- package/dist/meta/meta.controller.js.map +1 -1
- package/dist/meta/meta.module.js +8 -0
- package/dist/meta/meta.module.js.map +1 -1
- package/dist/meta/meta.service.d.ts +1 -1
- package/dist/meta/meta.service.js +3 -3
- package/dist/meta/meta.service.js.map +1 -1
- package/dist/subcommands/forceClean.module.js.map +1 -1
- package/dist/subcommands/forceClean.service.js +8 -4
- package/dist/subcommands/forceClean.service.js.map +1 -1
- package/dist/subcommands/reindex.init.js +5 -1
- package/dist/subcommands/reindex.init.js.map +1 -1
- package/dist/subcommands/reindex.module.js +10 -0
- package/dist/subcommands/reindex.module.js.map +1 -1
- package/dist/subcommands/reindex.service.d.ts +4 -1
- package/dist/subcommands/reindex.service.js +22 -12
- package/dist/subcommands/reindex.service.js.map +1 -1
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/reindex.d.ts +2 -1
- package/dist/utils/reindex.js +6 -2
- package/dist/utils/reindex.js.map +1 -1
- package/dist/yargs.d.ts +93 -53
- package/dist/yargs.js +113 -71
- package/dist/yargs.js.map +1 -1
- package/package.json +9 -8
- package/dist/indexer/blockDispatcher/base-block-dispatcher.d.ts +0 -40
- package/dist/indexer/blockDispatcher/base-block-dispatcher.js +0 -99
- package/dist/indexer/blockDispatcher/base-block-dispatcher.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-rpc-batch-provider.js","sourceRoot":"","sources":["../../../src/ethereum/ethers/json-rpc-batch-provider.ts"],"names":[],"mappings":";;;AAAA,oBAAoB;AACpB,0DAAqD;AACrD,4CAA+C;AAE/C,wDAA2D;
|
|
1
|
+
{"version":3,"file":"json-rpc-batch-provider.js","sourceRoot":"","sources":["../../../src/ethereum/ethers/json-rpc-batch-provider.ts"],"names":[],"mappings":";;;AAAA,oBAAoB;AACpB,0DAAqD;AACrD,4CAA+C;AAE/C,wDAA2D;AAG3D,gDAA6C;AAE7C,MAAM,MAAM,GAAG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,CAAC,EAAE,CAAC,CAAC;gBACtD,IAAI,OAAO,CAAC,KAAK,EAAE;oBACjB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;oBACzC,KAAM,CAAC,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;oBACjC,KAAM,CAAC,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;oBACvC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;iBAC/B;qBAAM;oBACL,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;iBACzC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,MAAM,EAAE,UAAU;gBAClB,KAAK,EAAE,KAAK;gBACZ,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC;YAEH,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAEpB,KAAK,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE;gBAChC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACF;AAtHD,oDAsHC","sourcesContent":["/* eslint-disable */\nimport { deepCopy } from '@ethersproject/properties';\nimport { fetchJson } from '@ethersproject/web';\n\nimport { JsonRpcProvider } from '@ethersproject/providers';\nimport { Networkish } from '@ethersproject/networks';\nimport { ConnectionInfo } from './web';\nimport { getLogger } from '@subql/node-core';\n\nconst logger = getLogger('JsonRpcBatchProvider');\n\ninterface RpcResult {\n jsonrpc: '2.0';\n id: number;\n result?: string;\n error?: {\n code: number;\n message: string;\n data?: any;\n };\n}\n\n// Experimental\n\nexport class JsonRpcBatchProvider extends JsonRpcProvider {\n _pendingBatchAggregator: NodeJS.Timer;\n _pendingBatch: Array<{\n request: { method: string; params: Array<any>; id: number; jsonrpc: '2.0' };\n resolve: (result: any) => void;\n reject: (error: Error) => void;\n }>;\n\n constructor(url: string | ConnectionInfo, network?: Networkish) {\n super(url, network);\n }\n\n send(method: string, params: Array<any>): Promise<any> {\n const request = {\n method: method,\n params: params,\n id: this._nextId++,\n jsonrpc: '2.0',\n };\n\n if (this._pendingBatch == null) {\n this._pendingBatch = [];\n }\n\n const inflightRequest: any = { request, resolve: null, reject: null };\n\n const promise = new Promise((resolve, reject) => {\n inflightRequest.resolve = resolve;\n inflightRequest.reject = reject;\n });\n\n this._pendingBatch.push(inflightRequest);\n\n if (!this._pendingBatchAggregator) {\n // Schedule batch for next event loop + short duration\n this._pendingBatchAggregator = setTimeout(() => {\n this.runRequests();\n }, 1);\n }\n\n if (this._pendingBatch.length > 10) {\n this.flush();\n }\n\n return promise;\n }\n\n flush(): void {\n if (this._pendingBatchAggregator) {\n clearTimeout(this._pendingBatchAggregator);\n this.runRequests();\n }\n }\n\n private runRequests() {\n // Get teh current batch and clear it, so new requests\n // go into the next batch\n const batch = this._pendingBatch;\n this._pendingBatch = null;\n this._pendingBatchAggregator = null;\n\n // Get the request as an array of requests\n const request = batch.map((inflight) => inflight.request);\n\n this.emit('debug', {\n action: 'requestBatch',\n request: deepCopy(request),\n provider: this,\n });\n\n return fetchJson(this.connection, JSON.stringify(request))\n .then((result: RpcResult[]) => {\n this.emit('debug', {\n action: 'response',\n request: request,\n response: result,\n provider: this,\n });\n\n // if (!Array.isArray(result)) {\n // result = [result];\n // }\n\n // https://github.com/ethers-io/ethers.js/pull/2657\n const resultMap = result.reduce((resultMap, payload) => {\n resultMap[payload.id] = payload;\n return resultMap;\n }, {} as Record<number, RpcResult>);\n\n // For each result, feed it to the correct Promise, depending\n // on whether it was a success or error\n batch.forEach((inflightRequest) => {\n const payload = resultMap[inflightRequest.request.id];\n if (payload.error) {\n const error = new Error(payload.error.message);\n (<any>error).code = payload.error.code;\n (<any>error).data = payload.error.data;\n inflightRequest.reject(error);\n } else {\n inflightRequest.resolve(payload.result);\n }\n });\n })\n .catch((error) => {\n this.emit('debug', {\n action: 'response',\n error: error,\n request: request,\n provider: this,\n });\n\n logger.error(error);\n\n batch.forEach((inflightRequest) => {\n inflightRequest.reject(error);\n });\n });\n }\n}\n"]}
|
|
@@ -41,8 +41,8 @@ function formatLog(log, block) {
|
|
|
41
41
|
var _a;
|
|
42
42
|
return (_a = block.transactions) === null || _a === void 0 ? void 0 : _a.find((tx) => tx.hash === log.transactionHash);
|
|
43
43
|
},
|
|
44
|
-
|
|
45
|
-
return JSON.stringify((0, lodash_1.omit)(this, ['transaction', 'block']));
|
|
44
|
+
toJSON() {
|
|
45
|
+
return JSON.stringify((0, lodash_1.omit)(this, ['transaction', 'block', 'toJSON']));
|
|
46
46
|
} });
|
|
47
47
|
}
|
|
48
48
|
exports.formatLog = formatLog;
|
|
@@ -52,13 +52,15 @@ function formatTransaction(tx) {
|
|
|
52
52
|
: undefined, maxPriorityFeePerGas: tx.maxPriorityFeePerGas
|
|
53
53
|
? handleNumber(tx.maxPriorityFeePerGas).toBigInt()
|
|
54
54
|
: undefined, receipt: undefined, // Filled in at AvalancheApi.fetchBlocks
|
|
55
|
-
|
|
56
|
-
return JSON.stringify((0, lodash_1.omit)(this, ['
|
|
55
|
+
toJSON() {
|
|
56
|
+
return JSON.stringify((0, lodash_1.omit)(this, ['block', 'receipt', 'toJSON']));
|
|
57
57
|
} });
|
|
58
58
|
}
|
|
59
59
|
exports.formatTransaction = formatTransaction;
|
|
60
60
|
function formatReceipt(receipt, block) {
|
|
61
|
-
return Object.assign(Object.assign({}, receipt), { from: handleAddress(receipt.from), to: handleAddress(receipt.to), blockNumber: handleNumber(receipt.blockNumber).toNumber(), cumulativeGasUsed: handleNumber(receipt.cumulativeGasUsed).toBigInt(), effectiveGasPrice: handleNumber(receipt.effectiveGasPrice).toBigInt(), gasUsed: handleNumber(receipt.gasUsed).toBigInt(), logs: receipt.logs.map(formatLog), status: Boolean(handleNumber(receipt.status).toNumber()), transactionIndex: handleNumber(receipt.transactionIndex).toNumber()
|
|
61
|
+
return Object.assign(Object.assign({}, receipt), { from: handleAddress(receipt.from), to: handleAddress(receipt.to), blockNumber: handleNumber(receipt.blockNumber).toNumber(), cumulativeGasUsed: handleNumber(receipt.cumulativeGasUsed).toBigInt(), effectiveGasPrice: handleNumber(receipt.effectiveGasPrice).toBigInt(), gasUsed: handleNumber(receipt.gasUsed).toBigInt(), logs: receipt.logs.map(formatLog), status: Boolean(handleNumber(receipt.status).toNumber()), transactionIndex: handleNumber(receipt.transactionIndex).toNumber(), toJSON() {
|
|
62
|
+
return JSON.stringify((0, lodash_1.omit)(this, ['toJSON']));
|
|
63
|
+
} });
|
|
62
64
|
}
|
|
63
65
|
exports.formatReceipt = formatReceipt;
|
|
64
66
|
//# sourceMappingURL=utils.ethereum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.ethereum.js","sourceRoot":"","sources":["../../src/ethereum/utils.ethereum.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;AAEtC,oDAAoD;AACpD,wDAAqD;AACrD,wDAAgD;AAShD,mCAA8B;AAE9B,SAAgB,YAAY,CAAC,GAAe;IAC1C,kDAAkD;IAClD,OAAO,IAAI,CAAC;AACd,CAAC;AAHD,oCAGC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,IAAI,EAAE;QAC5B,OAAO,IAAI,CAAC;KACb;IACD,OAAO,IAAA,oBAAU,EAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,YAAY,CAAC,KAAsB;IAC1C,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,OAAO,gBAAI,CAAC;KACb;IACD,IAAI,KAAK,KAAK,IAAI,EAAE;QAClB,OAAO,gBAAI,CAAC;KACb;IACD,OAAO,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E,wCAAwC;QAC5D,MAAM;YACJ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAA,aAAI,EAAC,IAAI,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;QACpE,CAAC,GACqB,CAAC;AAC3B,CAAC;AAzBD,8CAyBC;AAED,SAAgB,aAAa,CAC3B,OAA4B,EAC5B,KAAoB;IAEpB,OAAO,gCACF,OAAO,KACV,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EACjC,EAAE,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,EAC7B,WAAW,EAAE,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,EACzD,iBAAiB,EAAE,YAAY,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE,EACrE,iBAAiB,EAAE,YAAY,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE,EACrE,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EACjD,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,EACjC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,EACxD,gBAAgB,EAAE,YAAY,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,EACnE,MAAM;YACJ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAA,aAAI,EAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAChD,CAAC,GAC4B,CAAC;AAClC,CAAC;AAnBD,sCAmBC","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getAddress } from '@ethersproject/address';\nimport { BigNumber } from '@ethersproject/bignumber';\nimport { Zero } from '@ethersproject/constants';\nimport {\n ApiWrapper,\n EthereumBlock,\n EthereumLog,\n EthereumReceipt,\n EthereumResult,\n EthereumTransaction,\n} from '@subql/types-ethereum';\nimport { omit } from 'lodash';\n\nexport function calcInterval(api: ApiWrapper): number {\n // TODO find a way to get this from the blockchain\n return 6000;\n}\n\nfunction handleAddress(value: string): string | null {\n if (!value || value === '0x') {\n return null;\n }\n return getAddress(value);\n}\n\nfunction handleNumber(value: string | number): BigNumber {\n if (value === undefined) {\n return Zero;\n }\n if (value === '0x') {\n return Zero;\n }\n return BigNumber.from(value);\n}\n\nexport function formatBlock(block: Record<string, any>): EthereumBlock {\n return {\n ...block,\n difficulty: handleNumber(block.difficulty).toBigInt(),\n gasLimit: handleNumber(block.gasLimit).toBigInt(),\n gasUsed: handleNumber(block.gasUsed).toBigInt(),\n number: handleNumber(block.number).toNumber(),\n size: handleNumber(block.size).toBigInt(),\n timestamp: handleNumber(block.timestamp).toBigInt(),\n totalDifficulty: handleNumber(block.totalDifficulty).toBigInt(),\n baseFeePerGas: block.baseFeePerGas\n ? handleNumber(block.baseFeePerGas).toBigInt()\n : undefined,\n blockGasCost: block.blockGasCost\n ? handleNumber(block.blockGasCost).toBigInt()\n : undefined,\n logs: [], // Filled in at AvalancheBlockWrapped constructor\n } as EthereumBlock;\n}\nexport function formatLog(\n log: Omit<\n EthereumLog<EthereumResult> | EthereumLog,\n 'blockTimestamp' | 'block' | 'transaction'\n >,\n block: EthereumBlock,\n): EthereumLog<EthereumResult> | EthereumLog {\n return {\n ...log,\n address: handleAddress(log.address),\n blockNumber: handleNumber(log.blockNumber).toNumber(),\n transactionIndex: handleNumber(log.transactionIndex).toNumber(),\n logIndex: handleNumber(log.logIndex).toNumber(),\n block,\n get transaction() {\n return block.transactions?.find((tx) => tx.hash === log.transactionHash);\n },\n\n toJSON(): string {\n return JSON.stringify(omit(this, ['transaction', 'block', 'toJSON']));\n },\n } as EthereumLog<EthereumResult>;\n}\n\nexport function formatTransaction(\n tx: Record<string, any>,\n): EthereumTransaction {\n return {\n ...(tx as Partial<EthereumTransaction>),\n from: handleAddress(tx.from),\n to: handleAddress(tx.to),\n blockNumber: handleNumber(tx.blockNumber).toNumber(),\n gas: handleNumber(tx.gas).toBigInt(),\n gasPrice: handleNumber(tx.gasPrice).toBigInt(),\n nonce: handleNumber(tx.nonce).toBigInt(),\n transactionIndex: handleNumber(tx.transactionIndex).toBigInt(),\n value: handleNumber(tx.value).toBigInt(),\n v: handleNumber(tx.v).toBigInt(),\n maxFeePerGas: tx.maxFeePerGas\n ? handleNumber(tx.maxFeePerGas).toBigInt()\n : undefined,\n maxPriorityFeePerGas: tx.maxPriorityFeePerGas\n ? handleNumber(tx.maxPriorityFeePerGas).toBigInt()\n : undefined,\n receipt: undefined, // Filled in at AvalancheApi.fetchBlocks\n toJSON(): string {\n return JSON.stringify(omit(this, ['block', 'receipt', 'toJSON']));\n },\n } as EthereumTransaction;\n}\n\nexport function formatReceipt(\n receipt: Record<string, any>,\n block: EthereumBlock,\n): EthereumReceipt {\n return {\n ...receipt,\n from: handleAddress(receipt.from),\n to: handleAddress(receipt.to),\n blockNumber: handleNumber(receipt.blockNumber).toNumber(),\n cumulativeGasUsed: handleNumber(receipt.cumulativeGasUsed).toBigInt(),\n effectiveGasPrice: handleNumber(receipt.effectiveGasPrice).toBigInt(),\n gasUsed: handleNumber(receipt.gasUsed).toBigInt(),\n logs: receipt.logs.map(formatLog),\n status: Boolean(handleNumber(receipt.status).toNumber()),\n transactionIndex: handleNumber(receipt.transactionIndex).toNumber(),\n toJSON(): string {\n return JSON.stringify(omit(this, ['toJSON']));\n },\n } as unknown as EthereumReceipt;\n}\n"]}
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
import { OnApplicationShutdown } from '@nestjs/common';
|
|
2
2
|
import { EventEmitter2 } from '@nestjs/event-emitter';
|
|
3
|
-
import {
|
|
3
|
+
import { NodeConfig, SmartBatchService, StoreCacheService, StoreService, IProjectService, PoiService, BlockDispatcher, ProcessBlockResponse, ApiService } from '@subql/node-core';
|
|
4
|
+
import { EthereumBlockWrapper } from '@subql/types-ethereum';
|
|
5
|
+
import { SubqlProjectDs, SubqueryProject } from '../../configure/SubqueryProject';
|
|
6
|
+
import { DynamicDsService } from '../dynamic-ds.service';
|
|
4
7
|
import { IndexerManager } from '../indexer.manager';
|
|
5
|
-
import { ProjectService } from '../project.service';
|
|
6
|
-
import { BaseBlockDispatcher } from './base-block-dispatcher';
|
|
7
8
|
/**
|
|
8
9
|
* @description Intended to behave the same as WorkerBlockDispatcherService but doesn't use worker threads or any parallel processing
|
|
9
10
|
*/
|
|
10
|
-
export declare class BlockDispatcherService extends
|
|
11
|
-
private apiService;
|
|
11
|
+
export declare class BlockDispatcherService extends BlockDispatcher<EthereumBlockWrapper, SubqlProjectDs> implements OnApplicationShutdown {
|
|
12
12
|
private indexerManager;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
private fetchBlocksBatches;
|
|
17
|
-
constructor(apiService: ApiService, nodeConfig: NodeConfig, indexerManager: IndexerManager, eventEmitter: EventEmitter2, projectService: ProjectService);
|
|
18
|
-
init(onDynamicDsCreated: (height: number) => Promise<void>): Promise<void>;
|
|
19
|
-
onApplicationShutdown(): void;
|
|
20
|
-
enqueueBlocks(cleanedBlocks: number[], latestBufferHeight?: number): void;
|
|
21
|
-
flushQueue(height: number): void;
|
|
22
|
-
private fetchBlocksFromQueue;
|
|
13
|
+
constructor(apiService: ApiService, nodeConfig: NodeConfig, indexerManager: IndexerManager, eventEmitter: EventEmitter2, projectService: IProjectService, smartBatchService: SmartBatchService, storeService: StoreService, storeCacheService: StoreCacheService, poiService: PoiService, project: SubqueryProject, dynamicDsService: DynamicDsService);
|
|
14
|
+
protected getBlockHeight(block: EthereumBlockWrapper): number;
|
|
15
|
+
protected indexBlock(block: EthereumBlockWrapper): Promise<ProcessBlockResponse>;
|
|
23
16
|
}
|
|
@@ -10,137 +10,45 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
10
10
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
11
11
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
12
12
|
};
|
|
13
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
14
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
15
|
+
};
|
|
13
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
17
|
exports.BlockDispatcherService = void 0;
|
|
15
18
|
const common_1 = require("@nestjs/common");
|
|
16
19
|
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
17
20
|
const node_core_1 = require("@subql/node-core");
|
|
18
|
-
const
|
|
21
|
+
const SubqueryProject_1 = require("../../configure/SubqueryProject");
|
|
22
|
+
const dynamic_ds_service_1 = require("../dynamic-ds.service");
|
|
19
23
|
const indexer_manager_1 = require("../indexer.manager");
|
|
20
|
-
const project_service_1 = require("../project.service");
|
|
21
|
-
const base_block_dispatcher_1 = require("./base-block-dispatcher");
|
|
22
|
-
const logger = (0, node_core_1.getLogger)('BlockDispatcherService');
|
|
23
24
|
/**
|
|
24
25
|
* @description Intended to behave the same as WorkerBlockDispatcherService but doesn't use worker threads or any parallel processing
|
|
25
26
|
*/
|
|
26
|
-
let BlockDispatcherService = class BlockDispatcherService extends
|
|
27
|
-
constructor(apiService, nodeConfig, indexerManager, eventEmitter, projectService) {
|
|
28
|
-
super(nodeConfig, eventEmitter, projectService,
|
|
29
|
-
this.apiService = apiService;
|
|
27
|
+
let BlockDispatcherService = class BlockDispatcherService extends node_core_1.BlockDispatcher {
|
|
28
|
+
constructor(apiService, nodeConfig, indexerManager, eventEmitter, projectService, smartBatchService, storeService, storeCacheService, poiService, project, dynamicDsService) {
|
|
29
|
+
super(nodeConfig, eventEmitter, projectService, smartBatchService, storeService, storeCacheService, poiService, project, dynamicDsService, apiService.api.fetchBlocks.bind(apiService.api));
|
|
30
30
|
this.indexerManager = indexerManager;
|
|
31
|
-
this.fetching = false;
|
|
32
|
-
this.isShutdown = false;
|
|
33
|
-
this.processQueue = new node_core_1.AutoQueue(nodeConfig.batchSize * 3);
|
|
34
|
-
const fetchBlocks = this.apiService.api.fetchBlocks.bind(this.apiService.api);
|
|
35
|
-
if (this.nodeConfig.profiler) {
|
|
36
|
-
this.fetchBlocksBatches = (0, node_core_1.profilerWrap)(fetchBlocks, 'EthereumUtil', 'fetchBlocksBatches');
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
this.fetchBlocksBatches = fetchBlocks;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
43
|
-
async init(onDynamicDsCreated) {
|
|
44
|
-
this.onDynamicDsCreated = onDynamicDsCreated;
|
|
45
|
-
const blockAmount = await this.projectService.getProcessedBlockCount();
|
|
46
|
-
this.setProcessedBlockCount(blockAmount !== null && blockAmount !== void 0 ? blockAmount : 0);
|
|
47
|
-
}
|
|
48
|
-
onApplicationShutdown() {
|
|
49
|
-
this.isShutdown = true;
|
|
50
|
-
this.processQueue.abort();
|
|
51
|
-
}
|
|
52
|
-
enqueueBlocks(cleanedBlocks, latestBufferHeight) {
|
|
53
|
-
this.eventEmitter.emit('enqueueBlocks', cleanedBlocks.length);
|
|
54
|
-
if (cleanedBlocks.length) {
|
|
55
|
-
this.eventEmitter.emit('filteringBlocks', cleanedBlocks[cleanedBlocks.length - 1]);
|
|
56
|
-
}
|
|
57
|
-
// // In the case where factors of batchSize is equal to bypassBlock or when cleanedBatchBlocks is []
|
|
58
|
-
// // to ensure block is bypassed, latestBufferHeight needs to be manually set
|
|
59
|
-
// If cleanedBlocks = []
|
|
60
|
-
if (!!latestBufferHeight && !cleanedBlocks.length) {
|
|
61
|
-
this.latestBufferedHeight = latestBufferHeight;
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
logger.info(`Enqueueing blocks ${cleanedBlocks[0]}...${(0, lodash_1.last)(cleanedBlocks)}, total ${cleanedBlocks.length} blocks`);
|
|
65
|
-
this.queue.putMany(cleanedBlocks);
|
|
66
|
-
this.latestBufferedHeight = latestBufferHeight !== null && latestBufferHeight !== void 0 ? latestBufferHeight : (0, lodash_1.last)(cleanedBlocks);
|
|
67
|
-
void this.fetchBlocksFromQueue().catch((e) => {
|
|
68
|
-
logger.error(e, 'Failed to fetch blocks from queue');
|
|
69
|
-
if (!this.isShutdown) {
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
31
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this.processQueue.flush();
|
|
32
|
+
getBlockHeight(block) {
|
|
33
|
+
return block.blockHeight;
|
|
77
34
|
}
|
|
78
|
-
async
|
|
79
|
-
|
|
80
|
-
return;
|
|
81
|
-
// Process queue is full, no point in fetching more blocks
|
|
82
|
-
// if (this.processQueue.freeSpace < this.nodeConfig.batchSize) return;
|
|
83
|
-
this.fetching = true;
|
|
84
|
-
try {
|
|
85
|
-
while (!this.isShutdown) {
|
|
86
|
-
const blockNums = this.queue.takeMany(Math.min(this.nodeConfig.batchSize, this.processQueue.freeSpace));
|
|
87
|
-
// Used to compare before and after as a way to check if queue was flushed
|
|
88
|
-
const bufferedHeight = this._latestBufferedHeight;
|
|
89
|
-
// Queue is empty
|
|
90
|
-
if (!blockNums.length) {
|
|
91
|
-
// The process queue might be full so no block nums were taken, wait and try again
|
|
92
|
-
if (this.queue.size) {
|
|
93
|
-
await (0, node_core_1.delay)(1);
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
logger.info(`fetch block [${blockNums[0]},${blockNums[blockNums.length - 1]}], total ${blockNums.length} blocks`);
|
|
99
|
-
const blocks = await this.fetchBlocksBatches(blockNums);
|
|
100
|
-
// Check if the queues have been flushed between queue.takeMany and fetchBlocksBatches resolving
|
|
101
|
-
// Peeking the queue is because the latestBufferedHeight could have regrown since fetching block
|
|
102
|
-
if (bufferedHeight > this._latestBufferedHeight ||
|
|
103
|
-
this.queue.peek() < Math.min(...blockNums)) {
|
|
104
|
-
logger.info(`Queue was reset for new DS, discarding fetched blocks`);
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
const blockTasks = blocks.map((block) => async () => {
|
|
108
|
-
var _a;
|
|
109
|
-
const height = block.blockHeight;
|
|
110
|
-
try {
|
|
111
|
-
this.preProcessBlock(height);
|
|
112
|
-
const processBlockResponse = await this.indexerManager.indexBlock(block);
|
|
113
|
-
await this.postProcessBlock(height, processBlockResponse);
|
|
114
|
-
}
|
|
115
|
-
catch (e) {
|
|
116
|
-
if (this.isShutdown) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
logger.error(e, `failed to index block at height ${height} ${e.handler ? `${e.handler}(${(_a = e.stack) !== null && _a !== void 0 ? _a : ''})` : ''}`);
|
|
120
|
-
throw e;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
// There can be enough of a delay after fetching blocks that shutdown could now be true
|
|
124
|
-
if (this.isShutdown)
|
|
125
|
-
break;
|
|
126
|
-
this.processQueue.putMany(blockTasks);
|
|
127
|
-
this.eventEmitter.emit(node_core_1.IndexerEvent.BlockQueueSize, {
|
|
128
|
-
value: this.processQueue.size,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
finally {
|
|
133
|
-
this.fetching = false;
|
|
134
|
-
}
|
|
35
|
+
async indexBlock(block) {
|
|
36
|
+
return this.indexerManager.indexBlock(block);
|
|
135
37
|
}
|
|
136
38
|
};
|
|
137
39
|
BlockDispatcherService = __decorate([
|
|
138
40
|
(0, common_1.Injectable)(),
|
|
41
|
+
__param(4, (0, common_1.Inject)('IProjectService')),
|
|
42
|
+
__param(9, (0, common_1.Inject)('ISubqueryProject')),
|
|
139
43
|
__metadata("design:paramtypes", [node_core_1.ApiService,
|
|
140
44
|
node_core_1.NodeConfig,
|
|
141
45
|
indexer_manager_1.IndexerManager,
|
|
142
|
-
event_emitter_1.EventEmitter2,
|
|
143
|
-
|
|
46
|
+
event_emitter_1.EventEmitter2, Object, node_core_1.SmartBatchService,
|
|
47
|
+
node_core_1.StoreService,
|
|
48
|
+
node_core_1.StoreCacheService,
|
|
49
|
+
node_core_1.PoiService,
|
|
50
|
+
SubqueryProject_1.SubqueryProject,
|
|
51
|
+
dynamic_ds_service_1.DynamicDsService])
|
|
144
52
|
], BlockDispatcherService);
|
|
145
53
|
exports.BlockDispatcherService = BlockDispatcherService;
|
|
146
54
|
//# sourceMappingURL=block-dispatcher.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-dispatcher.service.js","sourceRoot":"","sources":["../../../src/indexer/blockDispatcher/block-dispatcher.service.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;;;;AAEtC,2CAAmE;AACnE,yDAAsD;AACtD,gDAS0B;AAC1B,mCAA8B;AAE9B,wDAAoD;AACpD,wDAAoD;AACpD,mEAA8D;AAE9D,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,wBAAwB,CAAC,CAAC;AAEnD;;GAEG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBACX,SAAQ,2CAAkC;IAS1C,YACU,UAAsB,EAC9B,UAAsB,EACd,cAA8B,EACtC,YAA2B,EAC3B,cAA8B;QAE9B,KAAK,CACH,UAAU,EACV,YAAY,EACZ,cAAc,EACd,IAAI,iBAAK,CAAC,UAAU,CAAC,SAAS,GAAG,CAAC,CAAC,CACpC,CAAC;QAXM,eAAU,GAAV,UAAU,CAAY;QAEtB,mBAAc,GAAd,cAAc,CAAgB;QAPhC,aAAQ,GAAG,KAAK,CAAC;QACjB,eAAU,GAAG,KAAK,CAAC;QAgBzB,IAAI,CAAC,YAAY,GAAG,IAAI,qBAAS,CAAC,UAAU,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;QAE5D,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,GA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,CAAC;qBACT;gBACH,CAAC,CAAC,CAAC;gBAEH,uFAAuF;gBACvF,IAAI,IAAI,CAAC,UAAU;oBAAE,MAAM;gBAE3B,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBAEtC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,wBAAY,CAAC,cAAc,EAAE;oBAClD,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI;iBAC9B,CAAC,CAAC;aACJ;SACF;gBAAS;YACR,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;SACvB;IACH,CAAC;CACF,CAAA;AA3KY,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAYW,sBAAU;QAClB,sBAAU;QACE,gCAAc;QACxB,6BAAa;QACX,gCAAc;GAfrB,sBAAsB,CA2KlC;AA3KY,wDAAsB","sourcesContent":["// Copyright 2020-2021 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Injectable, OnApplicationShutdown } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport {\n ApiService,\n getLogger,\n NodeConfig,\n IndexerEvent,\n delay,\n profilerWrap,\n AutoQueue,\n Queue,\n} from '@subql/node-core';\nimport { last } from 'lodash';\nimport { EthereumApiService } from '../../ethereum';\nimport { IndexerManager } from '../indexer.manager';\nimport { ProjectService } from '../project.service';\nimport { BaseBlockDispatcher } from './base-block-dispatcher';\n\nconst logger = getLogger('BlockDispatcherService');\n\n/**\n * @description Intended to behave the same as WorkerBlockDispatcherService but doesn't use worker threads or any parallel processing\n */\n@Injectable()\nexport class BlockDispatcherService\n extends BaseBlockDispatcher<Queue<number>>\n implements OnApplicationShutdown\n{\n private processQueue: AutoQueue<void>;\n\n private fetching = false;\n private isShutdown = false;\n private fetchBlocksBatches: EthereumApiService['api']['fetchBlocks'];\n\n constructor(\n private apiService: ApiService,\n nodeConfig: NodeConfig,\n private indexerManager: IndexerManager,\n eventEmitter: EventEmitter2,\n projectService: ProjectService,\n ) {\n super(\n nodeConfig,\n eventEmitter,\n projectService,\n new Queue(nodeConfig.batchSize * 3),\n );\n this.processQueue = new AutoQueue(nodeConfig.batchSize * 3);\n\n const fetchBlocks = this.apiService.api.fetchBlocks.bind(\n this.apiService.api,\n );\n if (this.nodeConfig.profiler) {\n this.fetchBlocksBatches = profilerWrap(\n fetchBlocks,\n 'EthereumUtil',\n 'fetchBlocksBatches',\n );\n } else {\n this.fetchBlocksBatches = fetchBlocks;\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async init(\n onDynamicDsCreated: (height: number) => Promise<void>,\n ): Promise<void> {\n this.onDynamicDsCreated = onDynamicDsCreated;\n const blockAmount = await this.projectService.getProcessedBlockCount();\n this.setProcessedBlockCount(blockAmount ?? 0);\n }\n\n onApplicationShutdown(): void {\n this.isShutdown = true;\n this.processQueue.abort();\n }\n\n enqueueBlocks(cleanedBlocks: number[], latestBufferHeight?: number): void {\n this.eventEmitter.emit('enqueueBlocks', cleanedBlocks.length);\n if (cleanedBlocks.length) {\n this.eventEmitter.emit(\n 'filteringBlocks',\n cleanedBlocks[cleanedBlocks.length - 1],\n );\n }\n // // In the case where factors of batchSize is equal to bypassBlock or when cleanedBatchBlocks is []\n // // to ensure block is bypassed, latestBufferHeight needs to be manually set\n // If cleanedBlocks = []\n if (!!latestBufferHeight && !cleanedBlocks.length) {\n this.latestBufferedHeight = latestBufferHeight;\n return;\n }\n\n logger.info(\n `Enqueueing blocks ${cleanedBlocks[0]}...${last(cleanedBlocks)}, total ${\n cleanedBlocks.length\n } blocks`,\n );\n\n this.queue.putMany(cleanedBlocks);\n\n this.latestBufferedHeight = latestBufferHeight ?? last(cleanedBlocks);\n void this.fetchBlocksFromQueue().catch((e) => {\n logger.error(e, 'Failed to fetch blocks from queue');\n if (!this.isShutdown) {\n process.exit(1);\n }\n });\n }\n\n flushQueue(height: number): void {\n super.flushQueue(height);\n this.processQueue.flush();\n }\n\n private async fetchBlocksFromQueue(): Promise<void> {\n if (this.fetching || this.isShutdown) return;\n // Process queue is full, no point in fetching more blocks\n // if (this.processQueue.freeSpace < this.nodeConfig.batchSize) return;\n\n this.fetching = true;\n\n try {\n while (!this.isShutdown) {\n const blockNums = this.queue.takeMany(\n Math.min(this.nodeConfig.batchSize, this.processQueue.freeSpace),\n );\n // Used to compare before and after as a way to check if queue was flushed\n const bufferedHeight = this._latestBufferedHeight;\n\n // Queue is empty\n if (!blockNums.length) {\n // The process queue might be full so no block nums were taken, wait and try again\n if (this.queue.size) {\n await delay(1);\n continue;\n }\n break;\n }\n\n logger.info(\n `fetch block [${blockNums[0]},${\n blockNums[blockNums.length - 1]\n }], total ${blockNums.length} blocks`,\n );\n\n const blocks = await this.fetchBlocksBatches(blockNums);\n\n // Check if the queues have been flushed between queue.takeMany and fetchBlocksBatches resolving\n // Peeking the queue is because the latestBufferedHeight could have regrown since fetching block\n if (\n bufferedHeight > this._latestBufferedHeight ||\n this.queue.peek() < Math.min(...blockNums)\n ) {\n logger.info(`Queue was reset for new DS, discarding fetched blocks`);\n continue;\n }\n\n const blockTasks = blocks.map((block) => async () => {\n const height = block.blockHeight;\n try {\n this.preProcessBlock(height);\n\n const processBlockResponse = await this.indexerManager.indexBlock(\n block,\n );\n\n await this.postProcessBlock(height, processBlockResponse);\n } catch (e) {\n if (this.isShutdown) {\n return;\n }\n logger.error(\n e,\n `failed to index block at height ${height} ${\n e.handler ? `${e.handler}(${e.stack ?? ''})` : ''\n }`,\n );\n throw e;\n }\n });\n\n // There can be enough of a delay after fetching blocks that shutdown could now be true\n if (this.isShutdown) break;\n\n this.processQueue.putMany(blockTasks);\n\n this.eventEmitter.emit(IndexerEvent.BlockQueueSize, {\n value: this.processQueue.size,\n });\n }\n } finally {\n this.fetching = false;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"block-dispatcher.service.js","sourceRoot":"","sources":["../../../src/indexer/blockDispatcher/block-dispatcher.service.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;;;;;;;AAEtC,2CAA2E;AAC3E,yDAAsD;AACtD,gDAU0B;AAE1B,qEAGyC;AACzC,8DAAyD;AACzD,wDAAoD;AAEpD;;GAEG;AAEH,IAAa,sBAAsB,GAAnC,MAAa,sBACX,SAAQ,2BAAqD;IAG7D,YACE,UAAsB,EACtB,UAAsB,EACd,cAA8B,EACtC,YAA2B,EACA,cAA+B,EAC1D,iBAAoC,EACpC,YAA0B,EAC1B,iBAAoC,EACpC,UAAsB,EACM,OAAwB,EACpD,gBAAkC;QAElC,KAAK,CACH,UAAU,EACV,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAChD,CAAC;QArBM,mBAAc,GAAd,cAAc,CAAgB;IAsBxC,CAAC;IAES,cAAc,CAAC,KAA2B;QAClD,OAAO,KAAK,CAAC,WAAW,CAAC;IAC3B,CAAC;IAES,KAAK,CAAC,UAAU,CACxB,KAA2B;QAE3B,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AAxCY,sBAAsB;IADlC,IAAA,mBAAU,GAAE;IAUR,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;IAKzB,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCATf,sBAAU;QACV,sBAAU;QACE,gCAAc;QACxB,6BAAa,UAER,6BAAiB;QACtB,wBAAY;QACP,6BAAiB;QACxB,sBAAU;QACe,iCAAe;QAClC,qCAAgB;GAfzB,sBAAsB,CAwClC;AAxCY,wDAAsB","sourcesContent":["// Copyright 2020-2021 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport {\n NodeConfig,\n SmartBatchService,\n StoreCacheService,\n StoreService,\n IProjectService,\n PoiService,\n BlockDispatcher,\n ProcessBlockResponse,\n ApiService,\n} from '@subql/node-core';\nimport { EthereumBlockWrapper } from '@subql/types-ethereum';\nimport {\n SubqlProjectDs,\n SubqueryProject,\n} from '../../configure/SubqueryProject';\nimport { DynamicDsService } from '../dynamic-ds.service';\nimport { IndexerManager } from '../indexer.manager';\n\n/**\n * @description Intended to behave the same as WorkerBlockDispatcherService but doesn't use worker threads or any parallel processing\n */\n@Injectable()\nexport class BlockDispatcherService\n extends BlockDispatcher<EthereumBlockWrapper, SubqlProjectDs>\n implements OnApplicationShutdown\n{\n constructor(\n apiService: ApiService,\n nodeConfig: NodeConfig,\n private indexerManager: IndexerManager,\n eventEmitter: EventEmitter2,\n @Inject('IProjectService') projectService: IProjectService,\n smartBatchService: SmartBatchService,\n storeService: StoreService,\n storeCacheService: StoreCacheService,\n poiService: PoiService,\n @Inject('ISubqueryProject') project: SubqueryProject,\n dynamicDsService: DynamicDsService,\n ) {\n super(\n nodeConfig,\n eventEmitter,\n projectService,\n smartBatchService,\n storeService,\n storeCacheService,\n poiService,\n project,\n dynamicDsService,\n apiService.api.fetchBlocks.bind(apiService.api),\n );\n }\n\n protected getBlockHeight(block: EthereumBlockWrapper): number {\n return block.blockHeight;\n }\n\n protected async indexBlock(\n block: EthereumBlockWrapper,\n ): Promise<ProcessBlockResponse> {\n return this.indexerManager.indexBlock(block);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ethereum-block-dispatcher.js","sourceRoot":"","sources":["../../../src/indexer/blockDispatcher/ethereum-block-dispatcher.ts"],"names":[],"mappings":";AAAA,kEAAkE;AAClE,sCAAsC","sourcesContent":["// / Copyright 2020-2021 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { IBlockDispatcher } from '@subql/node-core';\n\nexport interface IEthereumBlockDispatcher extends IBlockDispatcher {\n init(onDynamicDsCreated: (height: number) => Promise<void>): Promise<void>;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBlockDispatcher } from './base-block-dispatcher';
|
|
2
1
|
import { BlockDispatcherService } from './block-dispatcher.service';
|
|
2
|
+
import { IEthereumBlockDispatcher } from './ethereum-block-dispatcher';
|
|
3
3
|
import { WorkerBlockDispatcherService } from './worker-block-dispatcher.service';
|
|
4
|
-
export {
|
|
4
|
+
export { BlockDispatcherService, WorkerBlockDispatcherService, IEthereumBlockDispatcher, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/indexer/blockDispatcher/index.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/indexer/blockDispatcher/index.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;AAEtC,yEAAoE;AAKlE,uGALO,iDAAsB,OAKP;AAHxB,uFAAiF;AAI/E,6GAJO,8DAA4B,OAIP","sourcesContent":["// Copyright 2020-2021 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BlockDispatcherService } from './block-dispatcher.service';\nimport { IEthereumBlockDispatcher } from './ethereum-block-dispatcher';\nimport { WorkerBlockDispatcherService } from './worker-block-dispatcher.service';\n\nexport {\n BlockDispatcherService,\n WorkerBlockDispatcherService,\n IEthereumBlockDispatcher,\n};\n"]}
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import { OnApplicationShutdown } from '@nestjs/common';
|
|
2
2
|
import { EventEmitter2 } from '@nestjs/event-emitter';
|
|
3
|
-
import { NodeConfig,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
enqueueBlocks(heights: number[], latestBufferHeight?: number): void;
|
|
15
|
-
private enqueueBlock;
|
|
16
|
-
sampleWorkerStatus(): Promise<void>;
|
|
17
|
-
get latestBufferedHeight(): number;
|
|
18
|
-
set latestBufferedHeight(height: number);
|
|
19
|
-
private getNextWorkerIndex;
|
|
3
|
+
import { NodeConfig, SmartBatchService, StoreService, PoiService, StoreCacheService, IProjectService, WorkerBlockDispatcher } from '@subql/node-core';
|
|
4
|
+
import { SubqlProjectDs, SubqueryProject } from '../../configure/SubqueryProject';
|
|
5
|
+
import { DynamicDsService } from '../dynamic-ds.service';
|
|
6
|
+
import { UnfinalizedBlocksService } from '../unfinalizedBlocks.service';
|
|
7
|
+
import { IIndexerWorker } from '../worker/worker';
|
|
8
|
+
declare type IndexerWorker = IIndexerWorker & {
|
|
9
|
+
terminate: () => Promise<number>;
|
|
10
|
+
};
|
|
11
|
+
export declare class WorkerBlockDispatcherService extends WorkerBlockDispatcher<SubqlProjectDs, IndexerWorker> implements OnApplicationShutdown {
|
|
12
|
+
constructor(nodeConfig: NodeConfig, eventEmitter: EventEmitter2, projectService: IProjectService, smartBatchService: SmartBatchService, storeService: StoreService, storeCacheService: StoreCacheService, poiService: PoiService, project: SubqueryProject, dynamicDsService: DynamicDsService, unfinalizedBlocksSevice: UnfinalizedBlocksService);
|
|
13
|
+
protected fetchBlock(worker: IndexerWorker, height: number): Promise<void>;
|
|
20
14
|
}
|
|
15
|
+
export {};
|