Function cfxcore::pow::target_difficulty

source ·
pub fn target_difficulty<F>(
    data_man: &BlockDataManager,
    pow_config: &ProofOfWorkConfig,
    cur_hash: &H256,
    num_blocks_in_epoch: F
) -> U256
where F: Fn(&H256) -> usize,
Expand description

This function computes the target difficulty of the next period based on the current period. cur_hash should be the hash of the block at the current period upper boundary and it must have been inserted to BlockDataManager, otherwise the function will panic. num_blocks_in_epoch is a function that returns the epoch size under the epoch view of a given block.