Skip to content

Commit

Permalink
feat: add fast ingestion mode for faster replays (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr authored Sep 4, 2023
1 parent 9e5d2b1 commit 7996587
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/api/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { InscriptionsRoutes } from './routes/inscriptions';
import { SatRoutes } from './routes/sats';
import { StatsRoutes } from './routes/stats';
import { StatusRoutes } from './routes/status';
import { ENV } from '../env';

export const Api: FastifyPluginAsync<
Record<never, never>,
Expand All @@ -19,8 +20,8 @@ export const Api: FastifyPluginAsync<
await fastify.register(StatusRoutes);
await fastify.register(InscriptionsRoutes);
await fastify.register(SatRoutes);
await fastify.register(Brc20Routes);
await fastify.register(StatsRoutes);
if (ENV.BRC20_BLOCK_SCAN_ENABLED) await fastify.register(Brc20Routes);
};

export async function buildApiServer(args: { db: PgStore }) {
Expand Down
5 changes: 5 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ const schema = Type.Object({

/** Enables BRC-20 processing in write mode APIs */
BRC20_BLOCK_SCAN_ENABLED: Type.Boolean({ default: true }),
/**
* Disables inscription genesis/current location calculation, count aggregation, etc. so blocks
* can be ingested faster during a full replay.
*/
FAST_INGESTION_MODE: Type.Boolean({ default: false }),
});
type Env = Static<typeof schema>;

Expand Down
3 changes: 1 addition & 2 deletions src/pg/pg-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,7 @@ export class PgStore extends BasePgStore {
RETURNING inscription_id, id AS location_id, block_height, tx_index, address
`;
await this.updateInscriptionRecursions(writes);
if (ENV.BRC20_BLOCK_SCAN_ENABLED) {
// TODO: Temporary
if (!ENV.FAST_INGESTION_MODE) {
if (transferGenesisIds.size)
await sql`
UPDATE inscriptions
Expand Down

0 comments on commit 7996587

Please sign in to comment.