Function zebra_state::service::check::difficulty_threshold_and_time_are_valid
source · fn difficulty_threshold_and_time_are_valid(
difficulty_threshold: CompactDifficulty,
difficulty_adjustment: AdjustedDifficulty,
) -> Result<(), ValidateContextError>
Expand description
Validate the time and difficulty_threshold
from a candidate block’s
header.
Uses the difficulty_adjustment
context for the block to:
- check that the candidate block’s time is within the valid range, based on the network and candidate height, and
- check that the expected difficulty is equal to the block’s
difficulty_threshold
.
These checks are performed together, because the time field is used to calculate the expected difficulty adjustment.