Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions indexer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,30 @@ async fn main() -> anyhow::Result<()> {
),
};

let start_from = sink
.start_from(config.start_block)
.await
.context("Can't get starting point from sink")?;
tracing::info!("Passed start_block config: {:?}", config.start_block);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sink.start_from should be called anyway. doesn't matter if start_from is None. otherwise genesis data won't be processed

@gostkin gostkin Dec 18, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if start.is_empty() {
genesis::process_genesis(&self.db, &self.network, self.exec_plan.clone()).await?;
return self.get_latest_point().await;
}


let start_from_candidates = match config.start_block {
None => sink
.get_latest_points(15)
.await
.context("Can't get starting point from sink"),
Some(block_hash) => sink
.start_from(Option::from(block_hash))
.await
.context("Can't get starting point from config")
}?;

let start_from = start_from_candidates
.last()
.cloned()
.ok_or_else(|| anyhow!("Starting points list is empty"))?;

tracing::info!("Using start_from: {:?}", start_from);

match &config.source {
SourceConfig::Oura { .. } => {
let source = OuraSource::new(config.source, network, start_from.clone())
let source = OuraSource::new(config.source, network, start_from_candidates)
.context("Can't create oura source")?;
let start_from = start_from
.last()
.cloned()
.ok_or_else(|| anyhow!("Starting points list is empty"))?;

main_loop(source, sink, start_from, running, processing_finished).await
}
Expand All @@ -173,17 +184,6 @@ async fn main() -> anyhow::Result<()> {
_ => return Err(anyhow::anyhow!("network not supported by source")),
};

// try to find a confirmed point.
//
// this way the multiverse can be temporary, which saves setting up the extra db
// (at the expense of repulling some extra blocks at startup)
let start_from = sink
.get_latest_points(15)
.await?
.last()
.cloned()
.ok_or_else(|| anyhow!("Starting points list is empty"))?;

let network_config = dcspark_blockchain_source::cardano::NetworkConfiguration {
relay: relay.clone(),
from: start_from.clone(),
Expand Down