mino
February 17, 2020, 7:31pm
1
I have been monitoring the block difficulties for the last few weeks and can see a fair bit of fluctuation, but I cannot see what causes a change in the difficulty.

Can someone help me understand this? What factors create the change in difficulty? Is there a formula that governs this?

tromp
February 17, 2020, 10:11pm
2
It changes according to how long the last 60 blocks took to be solved:

/// Computes the proof-of-work difficulty that the next block should comply
/// with. Takes an iterator over past block headers information, from latest
/// (highest height) to oldest (lowest height).
///
/// The difficulty calculation is based on both Digishield and GravityWave
/// family of difficulty computation, coming to something very close to Zcash.
/// The reference difficulty is an average of the difficulty over a window of
/// DIFFICULTY_ADJUST_WINDOW blocks. The corresponding timespan is calculated
/// by using the difference between the median timestamps at the beginning
/// and the end of the window.
///
/// The secondary proof-of-work factor is calculated along the same lines, as
/// an adjustment on the deviation against the ideal value.
pub fn next_difficulty<T>(height: u64, cursor: T) -> HeaderInfo
where
T: IntoIterator<Item = HeaderInfo>,
{
// Create vector of difficulty data running from earliest
// to latest, and pad with simulated pre-genesis data to allow earlier
// adjustment if there isn't enough window data length will be

This file has been truncated. show original

1 Like

mino
February 18, 2020, 6:59am
3
Brilliant! Thanks John - that definitely answers the question.