Skip to content

Instantly share code, notes, and snippets.

@timbeiko

timbeiko/bomb.py Secret

Created January 27, 2022 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timbeiko/4c6d32852a1fab8c61b183ca3c273417 to your computer and use it in GitHub Desktop.
Save timbeiko/4c6d32852a1fab8c61b183ca3c273417 to your computer and use it in GitHub Desktop.
v bomb script
import time, random
from datetime import datetime
def get_bump(n):
return 2 ** ((n - 10700000) // 100000 - 2)
def simulate(hashrate, current_block):
difficulty = hashrate * 13
now = int(time.time())
block = current_block
last_block_time = now
last_interval_time = now
bump = get_bump(block)
for timestamp in range(now, now + 31556926):
if random.random() * difficulty < hashrate:
block += 1
delay = timestamp - last_block_time
difficulty_delta = (difficulty // 2048) * max(1 - delay // 9, -99)
difficulty += difficulty_delta
last_block_time = timestamp
difficulty += bump
if block % 100000 == 0:
d = datetime.fromtimestamp(timestamp)
datestring = d.strftime("%Y %b %d")
time_per_block = (
(timestamp - last_interval_time) /
min(100000, block - current_block)
)
last_interval_time = timestamp
bump = get_bump(block)
print('Block {} date {} last block interval {}'.format(
block, datestring, time_per_block
))
if __name__ == '__main__':
import sys
simulate(int(sys.argv[1]), int(sys.argv[2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment