Skip to content

Commit

Permalink
Prevent blocks from being skipped by ender (#639)
Browse files Browse the repository at this point in the history
* Prevent blocks from being skipped by ender

* fix

* fix tests
  • Loading branch information
Christopher-Li authored Oct 17, 2023
1 parent f0f134c commit f4da098
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('block-cache', () => {
[true, 'block.height == currentBlockHeight', '2', false],
[false, 'block.height == currentBlockHeight + 1', '3', false],
[false, 'block.height == currentBlockHeight + 1 with refresh', '4', true],
[false, 'block.height >= currentBlockHeight + 1 with refresh', '5', true],
[true, 'block.height >= currentBlockHeight + 1 with refresh', '5', true],
])('returns %s when %s', async (
skip: boolean,
_condition: string,
Expand Down
8 changes: 7 additions & 1 deletion indexer/services/ender/src/caches/block-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export async function shouldSkipBlock(
});
return true;
} else if (isNextBlock(blockHeight)) {
logger.info({
at: 'block-cache#shouldSkipBlock',
message: 'Block will be processed',
blockHeight,
currentBlockHeight,
});
return false;
} else if (canRefreshCache) {
const previousBlockHeight: string = getCurrentBlockHeight();
Expand All @@ -78,7 +84,7 @@ export async function shouldSkipBlock(
currentlyProcessingBlockHeight: blockHeight,
alreadyProcessedBlockHeight: getCurrentBlockHeight(),
});
return false;
return true;
}

function blockAlreadyProcessed(blockHeight: string): boolean {
Expand Down

0 comments on commit f4da098

Please sign in to comment.