- /// 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