Skip to content

Commit

Permalink
fix: select only the first inscription id match
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Nov 23, 2023
1 parent 2a23f69 commit 106368e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/pg/pg-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ export class PgStore extends BasePgStore {
for (const applyEvent of payload.apply) {
const event = applyEvent as BitcoinEvent;
const block_height = event.block_identifier.index;
if (block_height <= currentBlockHeight && block_height !== ORDINALS_GENESIS_BLOCK) {
if (
ENV.INSCRIPTION_GAP_DETECTION_ENABLED &&
block_height <= currentBlockHeight &&
block_height !== ORDINALS_GENESIS_BLOCK
) {
logger.info(
`PgStore skipping ingestion for previously seen block ${block_height}, current chain tip is at ${currentBlockHeight}`
);
Expand Down Expand Up @@ -654,7 +658,7 @@ export class PgStore extends BasePgStore {
`;
const locationData = writes.map(i => ({
...i.location,
inscription_id: sql`(SELECT id FROM inscriptions WHERE genesis_id = ${i.location.genesis_id})`,
inscription_id: sql`(SELECT id FROM inscriptions WHERE genesis_id = ${i.location.genesis_id} LIMIT 1)`,
timestamp: sql`TO_TIMESTAMP(${i.location.timestamp})`,
}));
const locations = await sql<DbLocationPointerInsert[]>`
Expand Down Expand Up @@ -896,8 +900,9 @@ export class PgStore extends BasePgStore {
for (const ref of refSet)
inserts.push({
inscription_id: this
.sql`(SELECT id FROM inscriptions WHERE genesis_id = ${i.inscription.genesis_id})`,
ref_inscription_id: this.sql`(SELECT id FROM inscriptions WHERE genesis_id = ${ref})`,
.sql`(SELECT id FROM inscriptions WHERE genesis_id = ${i.inscription.genesis_id} LIMIT 1)`,
ref_inscription_id: this
.sql`(SELECT id FROM inscriptions WHERE genesis_id = ${ref} LIMIT 1)`,
ref_inscription_genesis_id: ref,
});
}
Expand Down

0 comments on commit 106368e

Please sign in to comment.