def print_status_streaming(tx): # Create status request print("Hash of the transaction: ", tx.hash().hex()) tx_hash = tx.hash().blob() # Check python version if sys.version_info[0] == 2: tx_hash = ''.join(map(chr, tx_hash)) else: tx_hash = bytes(tx_hash) # Create request request = endpoint_pb2.TxStatusRequest() request.tx_hash = tx_hash # Create connection to Iroha channel = grpc.insecure_channel('127.0.0.1:50051') stub = endpoint_pb2_grpc.CommandServiceStub(channel) # Send request response = stub.StatusStream(request) for status in response: print("Status of transaction:") print(status)
def get_status(tx): # Create status request print("Hash of the transaction: ", tx.hash().hex()) tx_hash = tx.hash().blob() if sys.version_info[0] == 2: tx_hash = ''.join(map(chr, tx_hash)) else: tx_hash = bytes(tx_hash) request = endpoint_pb2.TxStatusRequest() request.tx_hash = tx_hash channel = grpc.insecure_channel('127.0.0.1:50051') stub = endpoint_pb2_grpc.CommandService_v1Stub(channel) response = stub.Status(request) status = endpoint_pb2.TxStatus.Name(response.tx_status) print("Status of transaction is:", status) if status != "COMMITTED": print("Your transaction wasn't committed") exit(1)
def get_tx_status(tx, address='127.0.0.1:50051'): """ Get status of the transaction :param tx: iroha transaction :param address: ip address and iroha port :return: status of tx transaction """ # Create status request print("Hash of the transaction: ", tx.hash().hex()) tx_hash = tx.hash().blob() if sys.version_info[0] == 2: tx_hash = ''.join(map(chr, tx_hash)) else: tx_hash = bytes(tx_hash) request = endpoint_pb2.TxStatusRequest() request.tx_hash = tx_hash # channel = grpc.insecure_channel(address) stub = endpoint_pb2_grpc.CommandServiceStub(channel) response = stub.Status(request) status = endpoint_pb2.TxStatus.Name(response.tx_status) return status
def tx_status(self, transaction): """ Request a status of a transaction :param transaction: the transaction, which status is about to be known :return: a tuple with the symbolic status description, integral status code, and error message string (will be empty if no error occurred) """ request = endpoint_pb2.TxStatusRequest() request.tx_hash = binascii.hexlify(IrohaCrypto.hash(transaction)) response = self._command_service_stub.Status(request) status_code = response.tx_status status_name = endpoint_pb2.TxStatus.Name(response.tx_status) error_message = response.error_message return status_name, status_code, error_message
def tx_status_stream(self, transaction): """ Generator of transaction statuses from status stream :param transaction: the transaction, which status is about to be known :return: an iterable over a series of tuples with symbolic status description, integral status code, and error message string (will be empty if no error occurred) """ request = endpoint_pb2.TxStatusRequest() request.tx_hash = binascii.hexlify(IrohaCrypto.hash(transaction)) response = self._command_service_stub.StatusStream(request) for status in response: status_name = endpoint_pb2.TxStatus.Name(status.tx_status) status_code = status.tx_status error_code = status.error_code yield status_name, status_code, error_code
def print_status_streaming(tx): # Create status request print("Hash of the transaction: ", tx.hash().hex()) tx_hash = tx.hash().hex() # Create request request = endpoint_pb2.TxStatusRequest() request.tx_hash = tx_hash # Create connection to Iroha channel = grpc.insecure_channel('127.0.0.1:50051') stub = endpoint_pb2_grpc.CommandService_v1Stub(channel) # Send request response = stub.StatusStream(request) for status in response: print("Status of transaction:") print(status)
proto_tx = block_pb2.Transaction() proto_tx.ParseFromString(''.join(map(chr, tx_blob))) channel = grpc.insecure_channel('127.0.0.1:50051') stub = endpoint_pb2_grpc.CommandServiceStub(channel) stub.Torii(proto_tx) time.sleep(5) # create status request print("Hash of the transaction: ", tx.hash().hex()) tx_hash = tx.hash().blob() tx_hash = ''.join(map(chr, tx_hash)) request = endpoint_pb2.TxStatusRequest() request.tx_hash = tx_hash response = stub.Status(request) status = endpoint_pb2.TxStatus.Name(response.tx_status) print("Status of transaction is:", status) if status != "COMMITTED": print("Your transaction wasn't committed") exit(1) query = query_builder.creatorAccountId(creator) \ .createdTime(current_time) \ .queryCounter(start_query_counter) \ .getAssetInfo("dollar#ru") \ .build()