Skip to content

Commit 645d6bf

Browse files
committed
feat(reku): update wait crosscheck logic
When `autoFollowLatestBlock` is `true`, `batchBlocksCount` becomes the minimum semantic
1 parent fcf5e42 commit 645d6bf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/reku/src/event/crosschecker/autochecker.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,19 @@ export class AutoCrossChecker extends BaseCrossChecker {
8888

8989
const waitNextCrosscheck = async (): Promise<boolean> => {
9090
latestBlockNum = await timeoutWithRetry(() => this.provider.provider?.getBlockNumber(), 15 * 1000, 3)
91+
92+
// If auto-follow is enabled, update toBlock and check block range
9193
if (options.autoFollowLatestBlock) {
9294
ccrOptions.toBlock = latestBlockNum
95+
96+
// Check if the range exceeds the latest block number
97+
if (ccrOptions.fromBlock + batchBlocksCount + delayBlockFromLatest > latestBlockNum)
98+
return false
99+
93100
return true
94101
}
95102

103+
// If auto-follow is not enabled, check if toBlock is within the delay range
96104
if (ccrOptions.toBlock + delayBlockFromLatest > latestBlockNum) {
97105
// sleep until the toBlock
98106
// await sleep((ccrOptions.toBlock + delayBlockFromLatest - latestBlockNum) * blockInterval)

0 commit comments

Comments
 (0)