Skip to content

Commit bfee668

Browse files
committed
fix: hash rates
1 parent 320cd43 commit bfee668

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

blockchain_job.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,17 @@ def get_latest_info():
3434
if response.status_code == 200:
3535
data = response.json()
3636
block_height=int(data['tipInfo']['metadata']['best_block_height'])
37-
currentShaHashRate=int(data['currentShaHashRate'])
38-
currentMoneroHashRate=int(data['currentMoneroHashRate'])
39-
return block_height, currentShaHashRate, currentMoneroHashRate
37+
currentShaHashRate=int(str(data['currentSha3xHashRate']).replace(',', ''))
38+
currentMoneroHashRate=int(str(data['currentMoneroRandomxHashRate']).replace(',', ''))
39+
currentTariRXHashRate=int(str(data['currentTariRandomxHashRate']).replace(',', ''))
40+
return block_height, currentShaHashRate, currentMoneroHashRate,currentTariRXHashRate
4041
else:
4142
raise Exception(f"Failed to fetch data: {response.status_code}")
4243

4344
async def post_block_height(client):
4445
try:
4546
# Fetch the block height stats
46-
block_height, x,y = get_latest_info()
47+
block_height, x,y,z = get_latest_info()
4748

4849
# List of sample questions
4950
questions = [
@@ -93,18 +94,20 @@ def schedule_block_height_job(client, loop):
9394
async def post_hash_power(client):
9495
try:
9596
# Fetch block height and hash rates
96-
block_height, current_sha_hash_rate, current_rx_hash_rate = get_latest_info()
97+
block_height, current_sha_hash_rate, current_rxm_hash_rate , current_rxt_hash_rate= get_latest_info()
9798

9899
# Format the hash rates with appropriate units
99100
formatted_sha_hash_rate = format_hash_rate(current_sha_hash_rate)
100-
formatted_rx_hash_rate = format_hash_rate(current_rx_hash_rate)
101+
formatted_rxm_hash_rate = format_hash_rate(current_rxm_hash_rate)
102+
formatted_rxt_hash_rate = format_hash_rate(current_rxt_hash_rate)
101103

102104
# Create the hash power stats message
103105
hash_power_stats = (
104106
f"📊 Current Tari Network Stats 📊\n"
105107
f"Block Height: {block_height:,}\n"
106-
f"SHA3 Hash Rate: {formatted_sha_hash_rate}\n"
107-
f"RandomX Hash Rate: {formatted_rx_hash_rate}\n\n"
108+
f"RandomX (Tari) Hash Rate: {formatted_rxt_hash_rate}\n"
109+
f"RandomX (Merged-Mined XMR) Hash Rate: {formatted_rxm_hash_rate}\n"
110+
f"SHA3x Hash Rate: {formatted_sha_hash_rate}\n\n"
108111
f"Want to learn more? Try '/faq mining' to get information about mining Tari."
109112
)
110113

@@ -139,4 +142,16 @@ def schedule_hash_power_job(client, loop):
139142
logging.info("Scheduler started for hash power job")
140143

141144

145+
if __name__ == "__main__":
146+
# test post hash power function
147+
# call and prin the result
148+
block_height, current_sha_hash_rate, current_rxm_hash_rate , current_rxt_hash_rate= get_latest_info()
149+
formatted_sha_hash_rate = format_hash_rate(current_sha_hash_rate)
150+
formatted_rxm_hash_rate = format_hash_rate(current_rxm_hash_rate)
151+
formatted_rxt_hash_rate = format_hash_rate(current_rxt_hash_rate)
152+
print(f"Block Height: {block_height:,}")
153+
print(f"RandomX (Tari) Hash Rate: {formatted_rxt_hash_rate}")
154+
print(f"RandomX (Merged-Mined XMR) Hash Rate: {formatted_rxm_hash_rate}")
155+
print(f"SHA3x Hash Rate: {formatted_sha_hash_rate}")
156+
142157

faqqer_bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ async def handler(event):
167167

168168
# Schedule the block height job
169169
#schedule_block_height_job(client , loop)
170-
#schedule_hash_power_job(client, loop)
170+
schedule_hash_power_job(client, loop)
171171
# Start the Telegram bot
172172
logging.info("Bot is running...")
173173
client.run_until_disconnected()

0 commit comments

Comments
 (0)