Skip to content

Commit

Permalink
fix: add ENV to toggle inscription gap detection
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Nov 23, 2023
1 parent 0ba671b commit 56ab283
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof schema>;

Expand Down
2 changes: 2 additions & 0 deletions src/pg/helpers.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 56ab283

Please sign in to comment.