def peer_count(): try: url = endpoint() response = HTTPClient(url).request("peerCount", []) except: return None return response
def block_number(): try: url = endpoint() response = HTTPClient(url).request("sushumna_blockNumber", "") except: return None return response
def call(params): try: url = endpoint() response = HTTPClient(url).request("eth_call", params) except: return None return response
def transaction_by_hash(tx_hash): try: url = endpoint() response = HTTPClient(url).request("getTransaction", tx_hash) except: return None return response
def get_receipt_by(tx_hash): try: url = endpoint() response = HTTPClient(url).request("eth_getTransactionReceipt", tx_hash) except: return None return response
def get_logs(topics): try: url = endpoint() response = HTTPClient(url).request("eth_getLogs", topics=topics, fromBlock=0) except: return None return response
def block_by_hash(params): try: url = endpoint() response = HTTPClient(url).request("sushumna_getBlockByHash", params) except: return None return response
def get_transaction_count(params): try: url = endpoint() response = HTTPClient(url).request("eth_getTransactionCount", params) except: return None return response
def block_by_number(params): try: url = endpoint() response = HTTPClient(url).request("cita_getBlockByNumber", params) except: return None return response
def send_transaction(params): try: url = endpoint() response = HTTPClient(url).request("calki_sendTransaction", params) except: return None return response
def get_code(params): try: url = endpoint() response = HTTPClient(url).request("getCode", params) except: return None return response
def block_number(): try: url = endpoint() response = HTTPClient(url).request("calki_blockNumber", []) except: return None return response
def get_tx_count(params): try: url = endpoint() response = HTTPClient(url).request("getTransactionCount", params) logger.debug(response) except: return None return response
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
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
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
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
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
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
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
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