add calculate.py, requirements.txt; update README.md
This commit is contained in:
parent
95faf38b3a
commit
283215ca1a
|
@ -4,4 +4,6 @@ This program calculates how much $WOW a certain hashrate can mine in a period of
|
|||
|
||||
All the logic was taken from [wownerod](https://git.wownero.com/wownero/wownero).
|
||||
|
||||
To install the dependencies simply run `pip install -r requirements.txt`.
|
||||
|
||||
License: GPL3.0
|
||||
|
|
67
calculate.py
Normal file
67
calculate.py
Normal file
|
@ -0,0 +1,67 @@
|
|||
# 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))
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
requests
|
Loading…
Reference in New Issue
Block a user