From 56ab283cdfaf95efe058e5f057fb5559b9dfede0 Mon Sep 17 00:00:00 2001 From: Rafael Cardenas Date: Thu, 23 Nov 2023 01:28:43 -0600 Subject: [PATCH] fix: add ENV to toggle inscription gap detection --- src/env.ts | 2 ++ src/pg/helpers.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/env.ts b/src/env.ts index 9f83eed3..c1de7e08 100644 --- a/src/env.ts +++ b/src/env.ts @@ -55,6 +55,8 @@ const schema = Type.Object({ /** Enables BRC-20 processing in write mode APIs */ BRC20_BLOCK_SCAN_ENABLED: Type.Boolean({ default: true }), + /** Enables inscription gap detection to prevent ingesting unordered blocks */ + INSCRIPTION_GAP_DETECTION_ENABLED: Type.Boolean({ default: true }), }); type Env = Static; diff --git a/src/pg/helpers.ts b/src/pg/helpers.ts index 443b45d2..9db08a1e 100644 --- a/src/pg/helpers.ts +++ b/src/pg/helpers.ts @@ -1,6 +1,7 @@ import { PgBytea } from '@hirosystems/api-toolkit'; import { hexToBuffer } from '../api/util/helpers'; import { BadPayloadRequestError } from '@hirosystems/chainhook-client'; +import { ENV } from '../env'; /** * Check if writing a block would create an inscription number gap @@ -13,6 +14,7 @@ export function assertNoBlockInscriptionGap(args: { currentBlockHeight: number; newBlockHeight: number; }) { + if (!ENV.INSCRIPTION_GAP_DETECTION_ENABLED) return; args.newNumbers.sort((a, b) => a - b); for (let n = 0; n < args.newNumbers.length; n++) { const curr = args.currentNumber + n;