Skip to content

Commit

Permalink
only compute the epoch if it's not done by the source
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed Sep 27, 2024
1 parent 33a4f35 commit 2829c3a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions indexer/src/sinks/cardano.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ impl Sink for CardanoSink {
// probably doesn't matter that much for the perf aggregator
// since it's only one block and it only happens once.
if let Some(shelley_era) = &self.shelley_era {
epoch = shelley_era.absolute_slot_to_epoch(epoch_slot.unwrap());
epoch =
epoch.or_else(|| shelley_era.absolute_slot_to_epoch(epoch_slot.unwrap()));
}

match epoch {
Expand Down Expand Up @@ -430,13 +431,14 @@ async fn insert_block(
known_time: 0,
slot_length: 0,
});
}

// in the byron era the epoch it's in the header, so we only need to compute
// this if we already transitioned to shelley.
if let Some(shelley_era) = &shelley_era {
block_global_info.epoch =
shelley_era.absolute_slot_to_epoch(block_global_info.epoch_slot.unwrap());
// in the byron era the epoch it's in the header, so we only need to compute
// this if we already transitioned to shelley.
if let Some(shelley_era) = &shelley_era {
block_global_info.epoch = block_global_info.epoch.or_else(|| {
shelley_era.absolute_slot_to_epoch(block_global_info.epoch_slot.unwrap())
});
}
}

perf_aggregator.block_parse += block_parse_counter.elapsed();
Expand Down

0 comments on commit 2829c3a

Please sign in to comment.