示例#1
0
def peer_count():
    try:
        url = endpoint()
        response = HTTPClient(url).request("peerCount", [])
    except:
        return None

    return response
示例#2
0
def block_number():
    try:
        url = endpoint()
        response = HTTPClient(url).request("sushumna_blockNumber", "")
    except:
        return None

    return response
示例#3
0
def call(params):
    try:
        url = endpoint()
        response = HTTPClient(url).request("eth_call", params)
    except:
        return None

    return response
示例#4
0
def transaction_by_hash(tx_hash):
    try:
        url = endpoint()
        response = HTTPClient(url).request("getTransaction", tx_hash)
    except:
        return None

    return response
示例#5
0
def get_receipt_by(tx_hash):
    try:
        url = endpoint()
        response = HTTPClient(url).request("eth_getTransactionReceipt", tx_hash)
    except:
        return None

    return response
示例#6
0
def get_logs(topics):
    try:
        url = endpoint()
        response = HTTPClient(url).request("eth_getLogs", topics=topics, fromBlock=0)
    except:
        return None

    return response
示例#7
0
def block_by_hash(params):
    try:
        url = endpoint()
        response = HTTPClient(url).request("sushumna_getBlockByHash", params)
    except:
        return None

    return response
示例#8
0
def get_transaction_count(params):
    try:
        url = endpoint()
        response = HTTPClient(url).request("eth_getTransactionCount", params)
    except:
        return None

    return response
示例#9
0
def block_by_number(params):
    try:
        url = endpoint()
        response = HTTPClient(url).request("cita_getBlockByNumber", params)
    except:
        return None

    return response
示例#10
0
def send_transaction(params):
    try:
        url = endpoint()
        response = HTTPClient(url).request("calki_sendTransaction", params)
    except:
        return None

    return response
示例#11
0
def get_code(params):
    try:
        url = endpoint()
        response = HTTPClient(url).request("getCode", params)
    except:
        return None

    return response
示例#12
0
def block_number():
    try:
        url = endpoint()
        response = HTTPClient(url).request("calki_blockNumber", [])
    except:
        return None

    return response
示例#13
0
def get_tx_count(params):
    try:
        url = endpoint()
        response = HTTPClient(url).request("getTransactionCount", params)
        logger.debug(response)
    except:
        return None

    return response
示例#14
0
def check_calki_status():
    result_status = False
    try:
        url = endpoint()
        response = HTTPClient(url).request("calki_blockNumber", [])
        result_status = response > 0
    except:
        result_status = False
    finally:
        return result_status
示例#15
0
def check_sushumna_status():
    result_status = False
    try:
        url = endpoint()
        response = HTTPClient(url).request("sushumna_blockNumber", "")
        result_status = response > 0
    except:
        result_status = False
    finally:
        return result_status
示例#16
0
def check_cita_status():
    result_status = False
    try:
        url = endpoint()
        response = HTTPClient(url).request("blockNumber", [])
        result_status = int(response, base=16) > 0
    except Exception as e:
        logger.error(e)
        result_status = False
    finally:
        return result_status
示例#17
0
def get_logs(topics, from_block, to_block):
    try:
        url = endpoint()
        response = HTTPClient(url).request("getLogs", [{
            "topics": topics,
            "fromBlock": from_block,
            "toBlock": to_block
        }])
    except:
        return None

    return response
示例#18
0
def send_transaction(params):
    if params is not None \
            and (len(params) < 2 or params[:2].lower() != '0x'):
        params = '0x' + params
    try:
        url = endpoint()
        response = HTTPClient(url).request("sendRawTransaction", params)
    except Exception as e:
        logger.error(e)
        return None

    return response
示例#19
0
def check_cita_status():
    result_status = False
    try:
        if ping(host()):
            url = endpoint()
            response = HTTPClient(url).request("cita_blockNumber", "")
            result_status = response > 0
        else:
            result_status = False
    except:
        result_status = False
    finally:
        return result_status
示例#20
0
def get_chainid():
    params = ['latest']
    chainid = 0

    try:
        url = endpoint()
        logger.debug(url)
        response = HTTPClient(url).request("getMetaData", params)
        chainid = response['chainId']
        logger.debug(response)
    except:
        chainid = 0

    logger.debug("final chainId is {}".format(chainid))
    return chainid
示例#21
0
def get_chainid_v1():
    params = ['latest']
    chainid = 1

    try:
        url = endpoint()
        logger.debug(url)
        response = HTTPClient(url).request("getMetaData", params)
        chainid = response['chainIdV1']
        logger.debug(response)
    except:
        chainid = "0x1"

    # padding to 32 bytes
    chainid = int(chainid, 16)
    logger.info("final chainId is {}".format(chainid))
    return chainid