Skip to content

Commit

Permalink
Merge pull request #253 from hirosystems/beta
Browse files Browse the repository at this point in the history
release v1.2.6
  • Loading branch information
rafaelcr authored Oct 11, 2023
2 parents 950b07d + 75a882e commit 1337143
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [1.2.6-beta.2](https://github.com/hirosystems/ordinals-api/compare/v1.2.6-beta.1...v1.2.6-beta.2) (2023-10-11)


### Bug Fixes

* use limit/offset instead of a cursor ([#252](https://github.com/hirosystems/ordinals-api/issues/252)) ([e4e9819](https://github.com/hirosystems/ordinals-api/commit/e4e98194973a36936d0adcf5069580e39a4ebbf5))

## [1.2.6-beta.1](https://github.com/hirosystems/ordinals-api/compare/v1.2.5...v1.2.6-beta.1) (2023-10-11)


### Bug Fixes

* scan brc-20 blocks using a cursor ([#251](https://github.com/hirosystems/ordinals-api/issues/251)) ([a1bf4b4](https://github.com/hirosystems/ordinals-api/commit/a1bf4b45eddc002610c6c6588c5ec45a2b64b0bb))

## [1.2.5](https://github.com/hirosystems/ordinals-api/compare/v1.2.4...v1.2.5) (2023-10-06)


Expand Down
33 changes: 21 additions & 12 deletions src/pg/brc20/brc20-pg-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,27 @@ export class Brc20PgStore extends BasePgStoreModule {
for (let blockHeight = startBlock; blockHeight <= endBlock; blockHeight++) {
logger.info(`Brc20PgStore scanning block ${blockHeight}`);
await this.sqlWriteTransaction(async sql => {
const block = await sql<DbBrc20ScannedInscription[]>`
SELECT
EXISTS(SELECT location_id FROM genesis_locations WHERE location_id = l.id) AS genesis,
l.id, l.inscription_id, l.block_height, l.tx_id, l.tx_index, l.address
FROM locations AS l
INNER JOIN inscriptions AS i ON l.inscription_id = i.id
WHERE l.block_height = ${blockHeight}
AND i.number >= 0
AND i.mime_type IN ('application/json', 'text/plain')
ORDER BY tx_index ASC
`;
await this.insertOperations(block);
const limit = 100_000;
let offset = 0;
do {
const block = await sql<DbBrc20ScannedInscription[]>`
SELECT
EXISTS(SELECT location_id FROM genesis_locations WHERE location_id = l.id) AS genesis,
l.id, l.inscription_id, l.block_height, l.tx_id, l.tx_index, l.address
FROM locations AS l
INNER JOIN inscriptions AS i ON l.inscription_id = i.id
WHERE l.block_height = ${blockHeight}
AND i.number >= 0
AND i.mime_type IN ('application/json', 'text/plain')
ORDER BY tx_index ASC
LIMIT ${limit}
OFFSET ${offset}
`;
if (block.count === 0) break;
await this.insertOperations(block);
if (block.count < limit) break;
offset += limit;
} while (true);
});
}
}
Expand Down

0 comments on commit 1337143

Please sign in to comment.