mirror of
https://github.com/wownero/diff-chart.git
synced 2026-10-17 15:21:25 +02:00
more compact data collection scheme, update wownero data
This commit is contained in:
+18
-10
@@ -32,8 +32,8 @@ from .rpc import JSONRPC
|
||||
|
||||
class Daemon(object):
|
||||
|
||||
def __init__(self, protocol='http', host='127.0.0.1', port=18081, path='/json_rpc'):
|
||||
self.rpc = JSONRPC('{protocol}://{host}:{port}{path}'.format(protocol=protocol, host=host, port=port, path=path))
|
||||
def __init__(self, protocol='http', host='127.0.0.1', port=18081):
|
||||
self.rpc = JSONRPC(protocol=protocol, host=host, port=port)
|
||||
|
||||
def getblocktemplate(self, address):
|
||||
getblocktemplate = {
|
||||
@@ -45,7 +45,7 @@ class Daemon(object):
|
||||
'jsonrpc': '2.0',
|
||||
'id': '0'
|
||||
}
|
||||
return self.rpc.send_request(getblocktemplate)
|
||||
return self.rpc.send_request('/json_rpc', getblocktemplate)
|
||||
|
||||
def get_block_headers_range(self, start_height, end_height):
|
||||
get_block_headers_range = {
|
||||
@@ -57,7 +57,7 @@ class Daemon(object):
|
||||
'jsonrpc': '2.0',
|
||||
'id': '0'
|
||||
}
|
||||
return self.rpc.send_request(get_block_headers_range)
|
||||
return self.rpc.send_request('/json_rpc', get_block_headers_range)
|
||||
|
||||
def submitblock(self, block):
|
||||
submitblock = {
|
||||
@@ -66,7 +66,7 @@ class Daemon(object):
|
||||
'jsonrpc': '2.0',
|
||||
'id': '0'
|
||||
}
|
||||
return self.rpc.send_request(submitblock)
|
||||
return self.rpc.send_request('/json_rpc', submitblock)
|
||||
|
||||
def getblock(self, height=0):
|
||||
getblock = {
|
||||
@@ -77,7 +77,15 @@ class Daemon(object):
|
||||
'jsonrpc': '2.0',
|
||||
'id': '0'
|
||||
}
|
||||
return self.rpc.send_request(getblock)
|
||||
return self.rpc.send_request('/json_rpc', getblock)
|
||||
|
||||
def gettransactions(self, tx_hashes):
|
||||
gettransactions = {
|
||||
'txs_hashes': tx_hashes,
|
||||
'decode_as_json': True,
|
||||
'prune': True
|
||||
}
|
||||
return self.rpc.send_request('/gettransactions', gettransactions)
|
||||
|
||||
def get_connections(self):
|
||||
get_connections = {
|
||||
@@ -85,7 +93,7 @@ class Daemon(object):
|
||||
'jsonrpc': '2.0',
|
||||
'id': '0'
|
||||
}
|
||||
return self.rpc.send_request(get_connections)
|
||||
return self.rpc.send_request('/json_rpc', get_connections)
|
||||
|
||||
def get_info(self):
|
||||
get_info = {
|
||||
@@ -93,7 +101,7 @@ class Daemon(object):
|
||||
'jsonrpc': '2.0',
|
||||
'id': '0'
|
||||
}
|
||||
return self.rpc.send_request(get_info)
|
||||
return self.rpc.send_request('/json_rpc', get_info)
|
||||
|
||||
def hard_fork_info(self):
|
||||
hard_fork_info = {
|
||||
@@ -101,7 +109,7 @@ class Daemon(object):
|
||||
'jsonrpc': '2.0',
|
||||
'id': '0'
|
||||
}
|
||||
return self.rpc.send_request(hard_fork_info)
|
||||
return self.rpc.send_request('/json_rpc', hard_fork_info)
|
||||
|
||||
def generateblocks(self, address, blocks=1):
|
||||
generateblocks = {
|
||||
@@ -114,4 +122,4 @@ class Daemon(object):
|
||||
'jsonrpc': '2.0',
|
||||
'id': '0'
|
||||
}
|
||||
return self.rpc.send_request(generateblocks)
|
||||
return self.rpc.send_request('/json_rpc', generateblocks)
|
||||
|
||||
@@ -30,19 +30,22 @@ import requests
|
||||
import json
|
||||
|
||||
class JSONRPC(object):
|
||||
def __init__(self, url):
|
||||
self.url = url
|
||||
def __init__(self, protocol, host, port):
|
||||
self.protocol = protocol
|
||||
self.host = host
|
||||
self.port = port
|
||||
|
||||
def send_request(self, inputs):
|
||||
def send_request(self, path, inputs):
|
||||
url = '{protocol}://{host}:{port}{path}'.format(protocol=self.protocol, host=self.host, port=self.port, path=path)
|
||||
res = requests.post(
|
||||
self.url,
|
||||
url,
|
||||
data=json.dumps(inputs),
|
||||
headers={'content-type': 'application/json'})
|
||||
res = res.json()
|
||||
|
||||
assert 'error' not in res, res
|
||||
|
||||
return res['result']
|
||||
return res['result'] if path == '/json_rpc' else res
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user