From 64fb4958ece430d3e4e9e0019f2c16c5fc845649 Mon Sep 17 00:00:00 2001 From: canonbrother Date: Wed, 22 Nov 2023 17:23:28 +0800 Subject: [PATCH] add enable index env --- apps/whale-api/src/app.configuration.ts | 4 ++++ apps/whale-api/src/module.indexer/rpc.block.provider.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/apps/whale-api/src/app.configuration.ts b/apps/whale-api/src/app.configuration.ts index 92ef71d0f6..dde121a27f 100644 --- a/apps/whale-api/src/app.configuration.ts +++ b/apps/whale-api/src/app.configuration.ts @@ -12,6 +12,9 @@ export function AppConfiguration (): any { /** * Allows you to override whale endpoint version. */ + enable: { + index: process.env.WHALE_ENABLE_INDEX + }, version: process.env.WHALE_VERSION, network: process.env.WHALE_NETWORK, defid: { @@ -30,6 +33,7 @@ export function AppConfiguration (): any { export function ENV_VALIDATION_SCHEMA (): any { return Joi.object({ NODE_ENV: Joi.string().optional(), + WHALE_ENABLE_INDEX: Joi.bool().optional(), WHALE_VERSION: Joi.string().optional(), WHALE_NETWORK: Joi.string().valid('mainnet', 'testnet', 'regtest', 'devnet', 'changi').default('regtest'), WHALE_DEFID_URL: Joi.string().optional(), diff --git a/apps/whale-api/src/module.indexer/rpc.block.provider.ts b/apps/whale-api/src/module.indexer/rpc.block.provider.ts index bb66b2d231..4bb9d1ba9f 100644 --- a/apps/whale-api/src/module.indexer/rpc.block.provider.ts +++ b/apps/whale-api/src/module.indexer/rpc.block.provider.ts @@ -33,6 +33,10 @@ export class RPCBlockProvider { return } + if (process.env.WHALE_ENABLE_INDEX === 'false') { + return + } + if (this.indexing) { return }