Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Weighted-Weighted Harmonic Mean (WWHM) difficulty algorithm
- # Original idea from Tom Harding (Deger8) called "WT-144"
- # No limits in rise or fall rate should be employed.
- # MTP should not be used.
- # ST = solvetime, T=target solvetime
- # height = most recently solved block
- # set constants
- # N=60 # See Masari coin for live data with N=60
- # T=600 # coin's Target solvetime. If this changes, nothing else needs to be changed.
- # adjust=0.99 # 0.98 for N=30, 0.99 for N=60
- # k = (N+1)/2 *adjust * T # there is not a missing N.
- # algorithm
- d=0, t=0, j=0
- previous_max=timestamp[height - N]
- for ( i = height-N+1; i < height+1; i++) { # (N most recent blocks)
- max_timestamp=max(timestamp[i], previous_max)
- solvetime = max_timestamp - previous_max
- solvetime=1 if solvetime < 1
- # for N=60, 10*T solvetimes drives difficulty too far down, so:
- solvetime = 10*T if solvetime > 10*T
- previous_max=max_timestamp
- j++
- t += solvetime * j
- d += D[i] # sum the difficulties this is how WWHM is different from Tom's WT.
- }
- t=T*N if t < T*N # in case of startup weirdness, keep t reasonable
- next_D = d * k / t
Add Comment
Please, Sign In to add comment