Guest User

Untitled

a guest
Jan 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. # Date, blocknum, difficulty as of 2019-01-18
  2. # Script by vbuterin, slightly modified by lrettig
  3. import random
  4. import datetime
  5. import sys
  6.  
  7. def calc_bomb(i):
  8. period = i // 100000
  9. if (period > 0):
  10. # Subtract 2, this is the original formula
  11. # Subtract another 30, this is the Byzantium delay
  12. return 2**(period - 32)
  13. return 0
  14.  
  15. def calc_difficulty_byzantium(i, cur_time, prev_diff, prev_time):
  16. new_diff = prev_diff + prev_diff // 2048 * max(1 - (cur_time - prev_time) // 9, -99)
  17. new_diff += calc_bomb(i)
  18. return new_diff
  19.  
  20. first_block = 7_087_671
  21. times = [1547823394]
  22. #diffs = [3_033_556_249_786_083]
  23. diffs = [2_580_831_000_000_000]
  24. hashpower = diffs[0] / 14
  25.  
  26. for i in range(first_block, 10_000_000):
  27. blocktime = random.expovariate(hashpower / diffs[-1])
  28. new_time = times[-1] + blocktime
  29. new_diff = calc_difficulty_byzantium(i, new_time, diffs[-1], times[-1])
  30. times.append(new_time)
  31. diffs.append(new_diff)
  32.  
  33. predicted_avg_blocktime = diffs[-1] / hashpower
  34.  
  35. if i % 10000 == 0:
  36. print('Block %d, time %r blocktime %.2f diffratio %.4f' % (
  37. i,
  38. datetime.datetime.utcfromtimestamp(times[-1]).isoformat().replace('T',' '),
  39. predicted_avg_blocktime,
  40. calc_bomb(i) / diffs[-1],
  41. ))
  42. if predicted_avg_blocktime > 60:
  43. sys.exit('Predicted block time exceeded 60s')
Add Comment
Please, Sign In to add comment