Skip to content

Commit

Permalink
fix(cu): trim last page of blocks meta according to maxTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
TillaTheHun0 committed Dec 20, 2023
1 parent 40ab5f5 commit a0f635b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions servers/cu/src/domain/client/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ export function loadBlocksMetaWith ({ fetch, GATEWAY_URL, pageSize, logger }) {
}

async function maybeFetchNext ({ pageInfo, edges, maxTimestamp }) {
if (!pageInfo.hasNextPage) return { pageInfo, edges }

/**
* HACK to incrementally fetch the correct range of blocks with only
* a timestamp as the right most limit.
Expand All @@ -158,6 +156,8 @@ export function loadBlocksMetaWith ({ fetch, GATEWAY_URL, pageSize, logger }) {
)
if (surpassedMaxTimestampIdx !== -1) return { pageInfo, edges: edges.slice(0, surpassedMaxTimestampIdx) }

if (!pageInfo.hasNextPage) return { pageInfo, edges }

/**
* Either have reached the end and resolve,
* or fetch the next page and recurse
Expand Down

0 comments on commit a0f635b

Please sign in to comment.