snuggleGuru

Untitled

Feb 13th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. # Weighted-Weighted Harmonic Mean (WWHM) difficulty algorithm
  2. # Original idea from Tom Harding (Deger8) called "WT-144"
  3. # No limits in rise or fall rate should be employed.
  4. # MTP should not be used.
  5. # ST = solvetime, T=target solvetime
  6. # height = most recently solved block
  7.  
  8. # set constants
  9. # N=60 # See Masari coin for live data with N=60
  10. # T=600 # coin's Target solvetime. If this changes, nothing else needs to be changed.
  11. # adjust=0.99 # 0.98 for N=30, 0.99 for N=60
  12. # k = (N+1)/2 *adjust * T # there is not a missing N.
  13.  
  14. # algorithm
  15. d=0, t=0, j=0
  16. previous_max=timestamp[height - N]
  17. for ( i = height-N+1; i < height+1; i++) { # (N most recent blocks)
  18. max_timestamp=max(timestamp[i], previous_max)
  19. solvetime = max_timestamp - previous_max
  20. solvetime=1 if solvetime < 1
  21. # for N=60, 10*T solvetimes drives difficulty too far down, so:
  22. solvetime = 10*T if solvetime > 10*T
  23. previous_max=max_timestamp
  24. j++
  25. t += solvetime * j
  26. d += D[i] # sum the difficulties this is how WWHM is different from Tom's WT.
  27. }
  28. t=T*N if t < T*N # in case of startup weirdness, keep t reasonable
  29. next_D = d * k / t
Add Comment
Please, Sign In to add comment