mirror of
https://git.wownero.com/lza_menace/tg-bot.git
synced 2024-08-15 00:23:12 +00:00
add mempool command
This commit is contained in:
parent
2d0dfc31fe
commit
a4febff15d
2 changed files with 21 additions and 3 deletions
|
@ -5,7 +5,7 @@ from tipbot.commands.tip import tip
|
|||
from tipbot.commands.withdraw import withdraw
|
||||
from tipbot.commands.balance import balance
|
||||
from tipbot.commands.deposit import deposit
|
||||
from tipbot.commands.mining import mine
|
||||
from tipbot.commands.mining import mine, mempool
|
||||
|
||||
|
||||
all_commands = {
|
||||
|
@ -47,5 +47,10 @@ all_commands = {
|
|||
'func': mine,
|
||||
'example': '/mine <hashes_per_second>',
|
||||
'help': 'Determine how much WOW a miner with given hashrate will earn'
|
||||
},
|
||||
'mempool': {
|
||||
'func': mempool,
|
||||
'example': '/mempool',
|
||||
'help': 'Determine how many transactions currently sit in the mempool'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ from tipbot import wownero
|
|||
from tipbot import config
|
||||
|
||||
|
||||
@wallet_rpc_required
|
||||
@log_event
|
||||
@check_debug
|
||||
def mine(update, context):
|
||||
|
@ -32,9 +31,23 @@ def mine(update, context):
|
|||
diff = float(j['result']['block_header']['difficulty'])
|
||||
lbr = float(j['result']['block_header']['reward'])
|
||||
ttb = diff / hr
|
||||
update.message.reply_text('The estimated time to find a block with {0:.2f} kh/s at diff {1:.2e} is {2:.2f} days. On average you will earn {3:.2f} WOW per day'.format(
|
||||
update.message.reply_text('The estimated time to find a block with {0:.2f} kH/s at diff {1:.2e} is {2:.2f} days. On average you will earn {3:.2f} WOW per day'.format(
|
||||
hr/1e3, diff, ttb/(60*60*24), (lbr/1e11)/(ttb/(60*60*24))
|
||||
))
|
||||
except:
|
||||
update.message.reply_text('Something b0rked -_-')
|
||||
return False
|
||||
|
||||
@log_event
|
||||
@check_debug
|
||||
def mempool(update, context):
|
||||
try:
|
||||
payload = {'jsonrpc':'2.0', 'id':'0', 'method':'get_info'}
|
||||
headers = {'Content-Type':'application/json'}
|
||||
r = requests.post(config.DAEMON_URI + '/json_rpc', json=payload, headers=headers, timeout=5)
|
||||
r.raise_for_status()
|
||||
j = r.json()
|
||||
txs = j['result']['tx_pool_size']
|
||||
update.message.reply_text('The current number of transactions in mempool is: {0}'.format(txs))
|
||||
except:
|
||||
update.message.reply_text('Something borked -_-')
|
||||
|
|
Loading…
Reference in a new issue