Skip to content

Commit 7d46abd

Browse files
committed
feat(reku): add debug logs
1 parent f59394b commit 7d46abd

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

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

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export class AutoCrossChecker extends BaseCrossChecker {
9292

9393
const waitNextCrosscheck = async (): Promise<boolean> => {
9494
latestBlockNum = await timeoutWithRetry(() => {
95+
// console.log(this.provider, this.provider.provider)
9596
if (!this.provider || !this.provider.provider)
9697
throw new Error('provider not ready')
9798
return this.provider.provider?.getBlockNumber()
@@ -142,20 +143,28 @@ export class AutoCrossChecker extends BaseCrossChecker {
142143
debug('crosscheck running')
143144

144145
// TODO: replace polling with schedule cron
145-
await polling(async () => {
146-
const wait = await waitOrUpdateToBlock()
147-
debug('polling interval: %d, wait: %s, from block: %d, to block: %d', pollingInterval, wait, ccrOptions.fromBlock, ccrOptions.toBlock)
148-
if (wait) {
149-
await this.crossCheckRange(ccrOptions)
150-
// only update options after cc succ
151-
await updateCCROptions(ccrOptions)
146+
polling(async () => {
147+
try {
148+
debug('start polling')
149+
const wait = await waitOrUpdateToBlock()
150+
debug('polling interval: %d, wait: %s, from block: %d, to block: %d', pollingInterval, wait, ccrOptions.fromBlock, ccrOptions.toBlock)
151+
if (wait) {
152+
await this.crossCheckRange(ccrOptions)
153+
// only update options after cc succ
154+
await updateCCROptions(ccrOptions)
155+
}
156+
else {
157+
debug('Because the latest block %d is too old, skip this cross check', latestBlockNum)
158+
}
159+
debug('end condition')
160+
const end = endingCondition()
161+
debug('polling ending condition: %s', end)
162+
return end
152163
}
153-
else {
154-
debug('Because the latest block %d is too old, skip this cross check', latestBlockNum)
164+
catch (error) {
165+
debug('polling error', error)
166+
return false
155167
}
156-
const end = endingCondition()
157-
debug('polling ending condition: %s', end)
158-
return end
159168
}, pollingInterval)
160169
}
161170

0 commit comments

Comments
 (0)