add network bit, rename file
This commit is contained in:
parent
a4febff15d
commit
246711b1f6
|
@ -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, mempool
|
||||
from tipbot.commands.network import mine, mempool, network
|
||||
|
||||
|
||||
all_commands = {
|
||||
|
@ -52,5 +52,10 @@ all_commands = {
|
|||
'func': mempool,
|
||||
'example': '/mempool',
|
||||
'help': 'Determine how many transactions currently sit in the mempool'
|
||||
}
|
||||
},
|
||||
'network': {
|
||||
'func': network,
|
||||
'example': '/network',
|
||||
'help': 'Show details about the Wownero network'
|
||||
},
|
||||
}
|
||||
|
|
|
@ -51,3 +51,21 @@ def mempool(update, context):
|
|||
update.message.reply_text('The current number of transactions in mempool is: {0}'.format(txs))
|
||||
except:
|
||||
update.message.reply_text('Something borked -_-')
|
||||
|
||||
@log_event
|
||||
@check_debug
|
||||
def network(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()
|
||||
height = j['result']['height']
|
||||
diff = j['result']['difficulty']
|
||||
hashrate = float(diff)/120
|
||||
update.message.reply_text('The current block height is {0:,}. Difficulty is {1:,}. Hashrate is {2:.2f} Mh/s.'.format(
|
||||
height, diff, hashrate/1e6
|
||||
))
|
||||
except:
|
||||
update.message.reply_text('Something borked -_-')
|
Loading…
Reference in New Issue