Skip to content

Commit

Permalink
fix: disable gap check during replay mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed May 14, 2024
1 parent b89802d commit f1f8d44
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const schema = Type.Object({
{ default: 'default', replay: 'replay' },
{ default: 'default' }
),
/** If the API should automatically shut down when Ordhook ingestion mode is `replay` */
ORDHOOK_REPLAY_INGESTION_MODE_AUTO_SHUTDOWN: Type.Boolean({ default: true }),

PGHOST: Type.String(),
PGPORT: Type.Number({ default: 5432, minimum: 0, maximum: 65535 }),
Expand Down
6 changes: 5 additions & 1 deletion src/ordhook/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ export async function startOrdhookServer(args: { db: PgStore }): Promise<Chainho
const server = new ChainhookEventObserver(serverOpts, ordhookOpts);
await server.start(predicates, async (uuid: string, payload: Payload) => {
const streamed = payload.chainhook.is_streaming_blocks;
if (ENV.ORDHOOK_INGESTION_MODE === 'replay' && streamed) {
if (
ENV.ORDHOOK_INGESTION_MODE === 'replay' &&
ENV.ORDHOOK_REPLAY_INGESTION_MODE_AUTO_SHUTDOWN &&
streamed

Check warning on line 65 in src/ordhook/server.ts

View check run for this annotation

Codecov / codecov/patch

src/ordhook/server.ts#L65

Added line #L65 was not covered by tests
) {
logger.info(`OrdhookServer finished replaying blocks, shutting down`);
return shutdown();
}
Expand Down
3 changes: 2 additions & 1 deletion src/pg/pg-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export class PgStore extends BasePgStore {
*/
async updateInscriptions(payload: BitcoinPayload): Promise<void> {
await this.sqlWriteTransaction(async sql => {
const streamed = payload.chainhook.is_streaming_blocks;
const streamed =
ENV.ORDHOOK_INGESTION_MODE === 'default' && payload.chainhook.is_streaming_blocks;
for (const event of payload.rollback) {
logger.info(`PgStore rollback block ${event.block_identifier.index}`);
const time = stopwatch();
Expand Down

0 comments on commit f1f8d44

Please sign in to comment.