@@ -92,6 +92,7 @@ export class AutoCrossChecker extends BaseCrossChecker {
92
92
93
93
const waitNextCrosscheck = async ( ) : Promise < boolean > => {
94
94
latestBlockNum = await timeoutWithRetry ( ( ) => {
95
+ // console.log(this.provider, this.provider.provider)
95
96
if ( ! this . provider || ! this . provider . provider )
96
97
throw new Error ( 'provider not ready' )
97
98
return this . provider . provider ?. getBlockNumber ( )
@@ -142,20 +143,28 @@ export class AutoCrossChecker extends BaseCrossChecker {
142
143
debug ( 'crosscheck running' )
143
144
144
145
// 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
152
163
}
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
155
167
}
156
- const end = endingCondition ( )
157
- debug ( 'polling ending condition: %s' , end )
158
- return end
159
168
} , pollingInterval )
160
169
}
161
170
0 commit comments