Browse Source

explorer/rpc_blocks: handle genesis height case when preparing next block to sync after reorg.

This commit adds a check to ensure that the genesis block is included when syncing blocks after a reorg resets the blockchain state to start block sync from block 0.
kalm 1 year ago
parent
commit
7e476b37c0
1 changed files with 4 additions and 2 deletions
  1. 4 2
      bin/explorer/explorerd/src/rpc_blocks.rs

+ 4 - 2
bin/explorer/explorerd/src/rpc_blocks.rs

@@ -104,8 +104,10 @@ impl Explorerd {
             if current_height != last_synced_height {
                 info!(target: "explorerd::rpc_blocks::sync_blocks", "Successfully completed reorg to height: {current_height}");
             }
-            // Prepare to sync the next block after reorg
-            current_height += 1;
+            // Prepare to sync the next block after reorg if not from genesis height
+            if current_height != 0 {
+                current_height += 1;
+            }
         } else if current_height != 0 {
             // Resume syncing from the block after the last synced height
             current_height += 1;