Skip to content

Commit

Permalink
feat. assert subscan paging limit of 100
Browse files Browse the repository at this point in the history
  • Loading branch information
kilted-andres committed Mar 20, 2024
1 parent 72d949c commit 933ef79
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/backend/revoker/subScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ export async function getEvents({
JSON.stringify(payloadForEventsListRequest, null, 2),
);

if (parameters.page >= 100) {
throw new Error(
`Page ${parameters.page} exceeds Subscan's paging limit of 100.`,
);
}

const {
data: { count, events },
} = await got
Expand Down Expand Up @@ -185,6 +191,7 @@ export async function* subScanEventGenerator(
`Found ${count} new "${eventId}" events on SubScan for in block range ${blockRange}.`,
);

// Subscan has a limit of 100 accessible pages for a given query.
const pages = Math.ceil(count / SUBSCAN_MAX_ROWS) - 1;

for (let page = 0; page <= pages; page++) {
Expand Down

0 comments on commit 933ef79

Please sign in to comment.