Skip to content

Commit

Permalink
add genesis checkpoint to indexer args, this will be used as the defa…
Browse files Browse the repository at this point in the history
…ult checkpoint.
  • Loading branch information
patrickkuo committed Jan 6, 2025
1 parent fa0b12b commit 5585c7e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion crates/sui-indexer-alt-framework/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ pub struct IndexerArgs {
/// Address to serve Prometheus Metrics from.
#[arg(long, default_value_t = Self::default().metrics_address)]
pub metrics_address: SocketAddr,

/// The genesis checkpoint to start ingestion from, this is useful for app indexer which only
/// needs to index checkpoint after the app contract's genesis.
#[arg(long, default_value_t = 0)]
pub genesis_checkpoint: u64,
}

pub struct Indexer {
Expand Down Expand Up @@ -101,6 +106,9 @@ pub struct Indexer {

/// The handles for every task spawned by this indexer, used to manage graceful shutdown.
handles: Vec<JoinHandle<()>>,

/// Default checkpoint lowerbound.
genesis_checkpoint: u64,
}

impl Indexer {
Expand Down Expand Up @@ -133,6 +141,7 @@ impl Indexer {
pipeline,
skip_watermark,
metrics_address,
genesis_checkpoint,
} = indexer_args;

let db = Db::new(db_args)
Expand Down Expand Up @@ -171,6 +180,7 @@ impl Indexer {
cancel,
first_checkpoint_from_watermark: u64::MAX,
handles: vec![],
genesis_checkpoint,
})
}

Expand Down Expand Up @@ -392,7 +402,9 @@ impl Indexer {
// TODO(amnn): Test this (depends on supporting migrations and tempdb).
self.first_checkpoint_from_watermark = watermark
.as_ref()
.map_or(0, |w| w.checkpoint_hi_inclusive as u64 + 1)
.map_or(self.genesis_checkpoint, |w| {
w.checkpoint_hi_inclusive as u64 + 1
})
.min(self.first_checkpoint_from_watermark);

Ok(Some(watermark))
Expand All @@ -407,6 +419,7 @@ impl Default for IndexerArgs {
pipeline: vec![],
skip_watermark: false,
metrics_address: "0.0.0.0:9184".parse().unwrap(),
genesis_checkpoint: 0,
}
}
}

0 comments on commit 5585c7e

Please sign in to comment.