Ejemplo n.º 1
0
    def GetTx(self, request, context):
        """get transaction

        :param request: tx_hash
        :param context:channel_loopchain_default
        :return:
        """
        channel_name = conf.LOOPCHAIN_DEFAULT_CHANNEL if request.channel == '' else request.channel

        channel_stub = StubCollection().channel_stubs[channel_name]
        tx = channel_stub.sync_task().get_tx(request.tx_hash)

        response_code, response_msg = message_code.get_response(
            message_code.Response.fail)
        response_meta = ""
        response_data = ""
        response_sign = b''
        response_public_key = b''

        if tx is not None:
            response_code, response_msg = message_code.get_response(
                message_code.Response.success)
            response_meta = json.dumps(tx.meta)
            response_data = tx.get_data().decode(conf.PEER_DATA_ENCODING)
            response_sign = tx.signature
            response_public_key = tx.public_key

        return loopchain_pb2.GetTxReply(response_code=response_code,
                                        meta=response_meta,
                                        data=response_data,
                                        signature=response_sign,
                                        public_key=response_public_key,
                                        more_info=response_msg)
Ejemplo n.º 2
0
    def GetTx(self, request, context):
        """ 트랜잭션을 가져옵니다.

        :param request: tx_hash
        :param context:
        :return:
        """
        tx = self.peer_service.block_manager.get_tx(request.tx_hash)

        # TODO 지금은 일반적인 fail 메시지로만 처리한다. 상세화 여지 있음, 필요시 추가 가능 (by winDy)
        response_code, response_msg = message_code.get_response(
            message_code.Response.fail)
        response_meta = ""
        response_data = ""

        if tx is not None:
            response_code, response_msg = message_code.get_response(
                message_code.Response.success)
            response_meta = json.dumps(tx.get_meta())
            response_data = tx.get_data().decode(conf.PEER_DATA_ENCODING)

        return loopchain_pb2.GetTxReply(response_code=response_code,
                                        meta=response_meta,
                                        data=response_data,
                                        more_info=response_msg)