pub fn retarget_algorithm(
    previous_target: &U256,
    first_timestamp: u32,
    second_timestamp: u32,
) -> U256 {
    let retarget_period = 1_209_600;
    let lower_bound = retarget_period / 4;
    let upper_bound = retarget_period * 4;

    let mut elapsed_time = second_timestamp - first_timestamp;
    elapsed_time = core::cmp::min(upper_bound, elapsed_time);
    elapsed_time = core::cmp::max(lower_bound, elapsed_time);

    previous_target * elapsed_time / retarget_period
}
/// Performs the bitcoin difficulty retarget.
/// Implements the Bitcoin algorithm precisely.
///
/// # Arguments
///
/// * `previous_target` - The target of the previous period
/// * `first_timestamp` - The timestamp of the first block in the difficulty period
/// * `second_timestamp` - The timestamp of the last block in the difficulty period
Performs the bitcoin difficulty retarget.
Implements the Bitcoin algorithm precisely.
Performs the bitcoin difficulty retarget . Implements the Bitcoin algorithm precisely .
pub fn retarget_algorithm(
    previous_target: &U256,
    first_timestamp: u32,
    second_timestamp: u32,
) -> U256 {
    let retarget_period = 1_209_600;
    let lower_bound = retarget_period / 4;
    let upper_bound = retarget_period * 4;
    let mut elapsed_time = second_timestamp - first_timestamp;
    elapsed_time = core::cmp::min(upper_bound, elapsed_time);
    elapsed_time = core::cmp::max(lower_bound, elapsed_time);
    previous_target * elapsed_time / retarget_period
}
pub fn retarget_algorithm ( previous_target : & U256 , first_timestamp : u32 , second_timestamp : u32 , ) -> U256 { let retarget_period = 1_209_600 ; let lower_bound = retarget_period / 4 ; let upper_bound = retarget_period * 4 ; let mut elapsed_time = second_timestamp - first_timestamp ; elapsed_time = core :: cmp :: min ( upper_bound , elapsed_time ) ; elapsed_time = core :: cmp :: max ( lower_bound , elapsed_time ) ; previous_target * elapsed_time / retarget_period }
Performs the bitcoin difficulty retarget.
Performs the bitcoin difficulty retarget .
previous_target
&U256
first_timestamp
u32
second_timestamp
u32
previous_target
&U256
first_timestamp
u32
second_timestamp
u32