Skip to content

Commit

Permalink
pr feedback: comment, move existing check to blockstore fn
Browse files Browse the repository at this point in the history
  • Loading branch information
AshwinSekar committed Aug 2, 2024
1 parent c7fcd27 commit 4da42a2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,8 @@ impl ReplayStage {
}

/// Checks if it is time for us to start producing a leader block.
/// Additionally fails if:
/// Fails if:
/// - Current PoH has not satisfied criteria to start my leader block
/// - Startup verification is not complete,
/// - Bank forks already contains a bank for this leader slot
/// - We have not landed a vote yet and the `wait_for_vote_to_start_leader` flag is set
Expand Down
7 changes: 7 additions & 0 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4049,6 +4049,13 @@ impl Blockstore {
Ok(duplicate_slots_iterator.map(|(slot, _)| slot))
}

pub fn has_existing_shreds_for_slot(&self, slot: Slot) -> bool {
match self.meta(slot).unwrap() {
Some(meta) => meta.received > 0,
None => false,
}
}

/// Returns the max root or 0 if it does not exist
pub fn max_root(&self) -> Slot {
self.max_root.load(Ordering::Relaxed)
Expand Down
9 changes: 1 addition & 8 deletions poh/src/poh_recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ impl PohRecorder {
return PohLeaderStatus::NotReached;
};

if self.has_existing_shreds_for_slot(next_poh_slot) {
if self.blockstore.has_existing_shreds_for_slot(next_poh_slot) {
// We already have existing shreds for this slot. This can happen when this block was previously
// created and added to BankForks, however a recent PoH reset caused this bank to be removed
// as it was not part of the rooted fork. If this slot is not the first slot for this leader,
Expand All @@ -594,13 +594,6 @@ impl PohRecorder {
}
}

fn has_existing_shreds_for_slot(&self, slot: Slot) -> bool {
match self.blockstore.meta(slot).unwrap() {
Some(meta) => meta.received > 0,
None => false,
}
}

// returns (leader_first_tick_height_including_grace_ticks, leader_last_tick_height, grace_ticks) given the next
// slot this recorder will lead
fn compute_leader_slot_tick_heights(
Expand Down

0 comments on commit 4da42a2

Please sign in to comment.