Skip to content

Commit a851445

Browse files
committed
feat(reku): add autoFollowLatestBlock option for AutoCrossChecker
1 parent e7bed58 commit a851445

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

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

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

8989
const waitNextCrosscheck = async (): Promise<boolean> => {
9090
latestBlockNum = await timeoutWithRetry(() => this.provider.provider?.getBlockNumber(), 15 * 1000, 3)
91+
if (options.autoFollowLatestBlock) {
92+
ccrOptions.toBlock = latestBlockNum
93+
return true
94+
}
95+
9196
if (ccrOptions.toBlock + delayBlockFromLatest > latestBlockNum) {
9297
// sleep until the toBlock
9398
// await sleep((ccrOptions.toBlock + delayBlockFromLatest - latestBlockNum) * blockInterval)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface AutoCrossCheckParam extends BaseCrossCheckParam {
3535
storeKeyPrefix?: string // set the prefix to all keys when set key-value to store (cache), e.g. key = prefix+txHashList
3636
storeTtl?: Milliseconds // the ttl for <txhash, log index> record in store
3737
batchBlocksCount?: number // how many blocks at most to get per check
38+
autoFollowLatestBlock?: boolean // whether to auto follow the latest block
3839
delayBlockFromLatest?: number // mostly for realtime mode; each time cc wait until latest height > toBlock + delayBlockFromLatest
3940
blockInterval?: Milliseconds // the block interval of the given chain, default: eth
4041
pollingInterval?: Milliseconds // mostly for limiting getLogs calling rate in catchup mode; how long does it take at least between 2 checks

0 commit comments

Comments
 (0)