68 lines
2.4 KiB
Python
68 lines
2.4 KiB
Python
# GPL3.0 licensed
|
|
# Developed by r3dwall
|
|
# http://git.qwik.i2p/r3dwall/wow-calculator
|
|
|
|
# Import requests to get latest informations
|
|
import requests
|
|
import sys
|
|
|
|
# Get hashrate
|
|
hr = float(input("Your current hashrate: "))
|
|
|
|
# Ask permission to make request
|
|
ask = input("Can I get the latest info to calculate?(Y/N): ")
|
|
if ask.lower() != "y":
|
|
print("To use a proxy, try proxychains")
|
|
sys.exit()
|
|
|
|
# Get data from last block
|
|
getlastblockheader = requests.post("http://muchwow.lol:34568/json_rpc", json={"jsonrpc":"2.0","id":"0","method":"getlastblockheader"}, headers={"Content-Type": "application/json"})
|
|
|
|
# Get general info from network
|
|
get_info = requests.post("http://muchwow.lol:34568/json_rpc", json={"jsonrpc":"2.0","id":"0","method":"get_info"}, headers={"Content-Type": "application/json"})
|
|
|
|
# Transform into a json readable format
|
|
get_info_json = get_info.json()
|
|
getlastblockheader_json = getlastblockheader.json()
|
|
|
|
# Declare necessary variables for calculation
|
|
difficulty = get_info_json["result"]["difficulty"] # Average number of hashes to find a valid one
|
|
block_target = get_info_json["result"]["target"] # Target time (in seconds) for the block to be mined
|
|
reward = getlastblockheader_json["result"]["block_header"]["reward"]/100000000000 # Amount of $WOW rewarded for mining a block
|
|
|
|
# Print some current information
|
|
print("Difficulty: {}".format(difficulty))
|
|
print("Block target: {} seconds".format(block_target))
|
|
print("Reward per block: {} WOW\n".format(reward))
|
|
|
|
# ratio is the division of the number of hashes to be generated in a block_target by the theorical needed number of hashes (difficulty)
|
|
ratio = (hr * block_target) / difficulty
|
|
|
|
# Daily, weekly, monthly and yearly expected rewards
|
|
daily = float('%.3f'%((86400 / block_target) * reward * ratio))
|
|
weekly = '%.3f'%(daily * 4.32)
|
|
monthly = '%.3f'%(daily * 30.5)
|
|
yearly = '%.3f'%(daily * 365)
|
|
|
|
# Array of units for time
|
|
units = {"seconds":1, "minutes":60, "hours":60, "days":24}
|
|
|
|
# Variables for storing the time values
|
|
unit = ""
|
|
time = difficulty / hr # Time in seconds to find a block
|
|
|
|
# Find the best unit
|
|
for u in units:
|
|
if time/units[u] < 1:
|
|
break
|
|
else:
|
|
unit = u
|
|
time = time / units[u]
|
|
|
|
# Round up the time
|
|
time = '%.3f'%(time)
|
|
|
|
# Print the results
|
|
print("With {0}H/s, it will take you around {1} {2} to mine a block".format(hr, time, unit))
|
|
print("Expected gains: {0} WOW daily, {1} WOW weekly, {2} WOW monthly and {3} WOW yearly".format(daily, weekly, monthly, yearly))
|