@@ -16,6 +16,7 @@ func InitReorg() {
1616}
1717
1818func RunReorgValidator () {
19+ lastBlockCheck := int64 (0 )
1920 for {
2021 startBlock , endBlock , err := getReorgRange ()
2122 if err != nil {
@@ -24,13 +25,20 @@ func RunReorgValidator() {
2425 continue
2526 }
2627
28+ if endBlock == lastBlockCheck || endBlock - startBlock < 5 {
29+ log .Debug ().Msg ("Not enough new blocks to check. Sleeping for 1 minute." )
30+ time .Sleep (1 * time .Minute )
31+ continue
32+ }
33+
2734 // Detect reorgs and handle them
2835 err = detectAndHandleReorgs (startBlock , endBlock )
2936 if err != nil {
3037 log .Error ().Err (err ).Msg ("Failed to detect and handle reorgs" )
3138 time .Sleep (2 * time .Second )
3239 continue
3340 }
41+ lastBlockCheck = endBlock
3442 }
3543}
3644
@@ -40,7 +48,7 @@ func getReorgRange() (int64, int64, error) {
4048 return 0 , 0 , fmt .Errorf ("failed to get last valid block: %w" , err )
4149 }
4250
43- startBlock := min (lastValidBlock - 1 , 1 )
51+ startBlock := max (lastValidBlock - 1 , 1 )
4452 endBlock , err := libs .GetMaxBlockNumberFromClickHouseV2 (libs .ChainId )
4553 if err != nil {
4654 return 0 , 0 , fmt .Errorf ("failed to get max block number: %w" , err )
0 commit comments