Skip to content

Commit

Permalink
dev(better_theoros): Prevent overflows in indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
akhercha committed Nov 3, 2024
1 parent 01b90f8 commit a65dc5d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rust/theoros/src/services/indexer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::cmp::max;

use anyhow::{anyhow, bail, Context, Result};
use apibara_core::{
node::v1alpha2::DataFinality,
Expand Down Expand Up @@ -61,7 +63,7 @@ impl IndexerService {
current_block: u64,
) -> Result<Self> {
let stream_config = Configuration::<Filter>::default()
.with_starting_block(current_block - START_INDEXER_DELTA)
.with_starting_block(max(1, current_block.saturating_sub(START_INDEXER_DELTA)))
.with_filter(|mut filter| {
filter
.with_header(HeaderFilter::weak())
Expand Down

0 comments on commit a65dc5d

Please sign in to comment.