Example #1
0
def info(port, ip='127.0.0.1'):
    response = requests.get(
        BASE_URL.replace('[ip]:[port]', '{}:{}'.format(ip, port)) +
        'state/info')
    if response.status_code != 200:
        print(
            colored('Unsuccessful call, code {}'.format(response.status_code),
                    'red'))
        return ''
    return response.json()
Example #2
0
def pending_size(port, ip='127.0.0.1'):
    response = requests.get(
        BASE_URL.replace('[ip]:[port]', '{}:{}'.format(ip, port)) +
        'state/pending_size')
    if response.status_code != 200:
        print(
            colored('Unsuccessful call, code {}'.format(response.status_code),
                    'red'))
        return -1
    return int(response.json()['num'])
Example #3
0
def write_tx(port, ip, c, data):
    response = requests.post(
        BASE_URL.replace('[ip]:[port]', '{}:{}'.format(ip, port)) +
        'transactions/cid={}?data={}'.format(c, data))  #, data={'data': data})
    if response.status_code != 200:
        print(
            colored('Unsuccessful call, code {}'.format(response.status_code),
                    'red'))
        return ''
    return response.json()
Example #4
0
def get_block(port, ip, c, h, blocking=0):
    response = requests.get(
        BASE_URL.replace('[ip]:[port]', '{}:{}'.format(ip, port)) +
        'blocks/cid={}&height={}&blocking={}'.format(c, h, blocking))
    if response.status_code != 200:
        print(
            colored('Unsuccessful call, code {}'.format(response.status_code),
                    'red'))
        return ''
    return response.json()
Example #5
0
def get_tx_data(port, ip, c, w, p, b, t, blocking=0):
    response = requests.get(
        BASE_URL.replace('[ip]:[port]', '{}:{}'.format(ip, port)) +
        'transactions/cid={}&worker={}&pid={}&bid={}&tx_num={}&blocking={}/data'
        .format(c, w, p, b, t, blocking))
    if response.status_code != 200:
        print(
            colored('Unsuccessful call, code {}'.format(response.status_code),
                    'red'))
        return ''
    return response.json()
Example #6
0
def get_ranking(edition, stage):
    response = urllib2.urlopen(BASE_URL.format(edition, stage))
    html = response.read()
    return html
Example #7
0
 def __init__(self, quesionid):
     self.quesionid = quesionid
     self.url = BASE_URL.format(question_id=quesionid)