Skip to content

Commit

Permalink
fix edge case of missing header data for estimation (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsutton authored Jan 26, 2024
1 parent 0004739 commit 540a354
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions consensus/src/consensus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,10 @@ impl ConsensusApi for Consensus {
Some(hash) => {
self.validate_block_exists(hash)?;
let ghostdag_data = self.ghostdag_primary_store.get_data(hash).unwrap();
// The selected parent header is used within to check for sampling activation, so we verify its existence first
if !self.headers_store.has(ghostdag_data.selected_parent).unwrap() {
return Err(ConsensusError::DifficultyError(DifficultyError::InsufficientWindowData(0)));
}
self.estimate_network_hashes_per_second_impl(&ghostdag_data, window_size)
}
None => {
Expand Down

0 comments on commit 540a354

Please sign in to comment.