Skip to main content

next_required_bits

Function next_required_bits 

Source
pub fn next_required_bits(
    network: Network,
    height: u64,
    block_timestamp: u64,
    ancestor: &dyn Fn(u64) -> Option<(u64, u64)>,
) -> Result<Option<u64>, ConsensusError>
Expand description

Compact nBits the block at height must carry.

Off a difficulty boundary the result is the parent’s bits. On a boundary it is the retarget of that period, unless the network does not retarget. Testnet and regtest may use the proof-of-work limit when the block is more than two target spacings after its parent; otherwise the bits are those of the last block in the period that is not itself a minimum-difficulty block.

ancestor(height) returns that block’s compact bits and timestamp. Height 0 has no parent and returns Ok(None).

This is not get_next_work_required. That function always retargets from whatever headers it is given.