Skip to content

Commit

Permalink
Returns an error instead of panicking when the relevant chain is empty (
Browse files Browse the repository at this point in the history
  • Loading branch information
arya2 authored Sep 23, 2024
1 parent c8280d4 commit d6301a6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions zebra-state/src/service/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,16 @@ where
.take(POW_ADJUSTMENT_BLOCK_SPAN)
.collect();

let parent_block = relevant_chain
.first()
.expect("state must contain parent block to do contextual validation");
let Some(parent_block) = relevant_chain.first() else {
warn!(
?semantically_verified,
?finalized_tip_height,
"state must contain parent block to do contextual validation"
);

return Err(ValidateContextError::NotReadyToBeCommitted);
};

let parent_block = parent_block.borrow();
let parent_height = parent_block
.coinbase_height()
Expand Down

0 comments on commit d6301a6

Please sign in to comment.