Skip to content

Commit

Permalink
fix(indexer): skip historical sync if we have reached or surpassed th…
Browse files Browse the repository at this point in the history
…e Dencun fork
  • Loading branch information
PJColombo committed Mar 10, 2024
1 parent 0d974fc commit 02b97e7
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/indexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ impl Indexer {
Some(block_id) => block_id,
None => match &sync_state {
Some(state) => match state.last_lower_synced_slot {
Some(slot) => BlockId::Slot(slot - 1),
Some(slot) => BlockId::Slot(self._get_current_lower_slot(slot)),
None => match state.last_upper_synced_slot {
Some(slot) => BlockId::Slot(slot - 1),
Some(slot) => BlockId::Slot(self._get_current_lower_slot(slot)),
None => BlockId::Head,
},
},
Expand Down Expand Up @@ -135,6 +135,18 @@ impl Indexer {
let target_lowest_slot = self.dencun_fork_slot;

tokio::spawn(async move {
// Skip historical sync if we are already at the target lowest slot
if let BlockId::Slot(slot) = start_block_id {
if slot <= target_lowest_slot {
debug!(
target = "indexer:historical_sync",
"Skip sync. Dencun fork slot reached"
);

return Ok(());
}
}

let result = synchronizer
.run(&start_block_id, &BlockId::Slot(target_lowest_slot))
.await;
Expand Down Expand Up @@ -314,4 +326,8 @@ impl Indexer {

synchronizer_builder.build(self.context.clone())
}

fn _get_current_lower_slot(&self, last_synced_slot: u32) -> u32 {
cmp::max(last_synced_slot, self.dencun_fork_slot)

Check failure on line 331 in src/indexer/mod.rs

View workflow job for this annotation

GitHub Actions / lint

failed to resolve: use of undeclared crate or module `cmp`

error[E0433]: failed to resolve: use of undeclared crate or module `cmp` --> src/indexer/mod.rs:331:9 | 331 | cmp::max(last_synced_slot, self.dencun_fork_slot) | ^^^ use of undeclared crate or module `cmp` | help: consider importing one of these items | 1 + use core::cmp; | 1 + use std::cmp; |
}
}

0 comments on commit 02b97e7

Please sign in to comment.