From 283215ca1a745847821bf4bcd208a27848d38155 Mon Sep 17 00:00:00 2001 From: r3dwall Date: Sun, 22 Oct 2023 00:10:03 -0300 Subject: [PATCH] add calculate.py, requirements.txt; update README.md --- README.md | 2 ++ calculate.py | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 1 + 3 files changed, 70 insertions(+) create mode 100644 calculate.py create mode 100644 requirements.txt diff --git a/README.md b/README.md index 2f9f37b..9ccead8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/calculate.py b/calculate.py new file mode 100644 index 0000000..ca86e74 --- /dev/null +++ b/calculate.py @@ -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)) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f229360 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests