Skip to content

Commit

Permalink
make sure to include the block 0
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed May 20, 2024
1 parent db1a0bb commit d6b9ad2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions blockchain-source/src/cardano/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@ async fn request_handler(

let mut current_handle = handle.take().unwrap();

let from = if from
let (from, ignore_first_block) = if from
== vec![Point::BlockHeader {
slot_nb: 0.into(),
hash: network_config.genesis_parent.clone(),
}] {
vec![network_config.genesis.clone()]
(vec![network_config.genesis.clone()], false)
} else {
from
(from, true)
};

if let Err(e) = block_fetch(
Expand All @@ -217,6 +217,7 @@ async fn request_handler(
&mut last_tip_event,
tip_update_pace,
&network_config,
ignore_first_block,
)
.await
{
Expand All @@ -238,6 +239,7 @@ async fn block_fetch(
last_tip_event: &mut Instant,
tip_update_pace: Duration,
network_config: &NetworkConfiguration,
ignore_first_block: bool,
) -> Result<()> {
let points: Result<Vec<_>> = from
.into_iter()
Expand Down Expand Up @@ -294,9 +296,11 @@ async fn block_fetch(
}
};

// the from in request_range is inclusive, but the from in `pull` is not supposed to be
// included, so skip the first block (which will be one of the checkpoints)
let _ = block_fetcher.next().await?;
if ignore_first_block {
// the from in request_range is inclusive, but the from in `pull` is not supposed to be
// included, so skip the first block (which will be one of the checkpoints)
let _ = block_fetcher.next().await?;
}

while let Some(raw_block) = block_fetcher.next().await? {
let event = BlockEvent::from_serialized_block(
Expand Down

0 comments on commit d6b9ad2

Please sign in to comment.