PermittedDifficultyTransition

Return false if the proof-of-work requirement specified by new_nbits at a given height is not possible, given the proof-of-work on the prior block as specified by old_nbits.

Synopsis

Declared in <pow.h>

bool
PermittedDifficultyTransition(
    Consensus::Params const& params,
    int64_t height,
    uint32_t old_nbits,
    uint32_t new_nbits);

Description

This function only checks that the new value is within a factor of 4 of the old value for blocks at the difficulty adjustment interval, and otherwise requires the values to be the same.

Always returns true on networks where min difficulty blocks are allowed, such as regtest/testnet.

Return Value

true if the transition from old_nbits to new_nbits is permitted.

Parameters

NameDescription
paramsThe consensus parameters for the active chain.
heightThe height of the block whose target is being validated.
old_nbitsThe proof-of-work target of the prior block, in compact form.
new_nbitsThe proposed proof-of-work target, in compact form.