Ejemplo n.º 1
0
    def send(self, transactions):
        txn_signatures = [txn.header_signature for txn in transactions]

        header = BatchHeader(
            signer_public_key=self.identity_signer.get_public_key().as_hex(),
            transaction_ids=txn_signatures).SerializeToString()

        signature = self.identity_signer.sign(header)

        batch = Batch(header=header,
                      transactions=transactions,
                      header_signature=signature)

        future = self._stream.send(
            message_type=Message.CLIENT_BATCH_SUBMIT_REQUEST,
            content=ClientBatchSubmitRequest(
                batches=[batch]).SerializeToString())
        LOGGER.debug('_BatchPublisherProxy: future.result ...')
        result = future.result()
        LOGGER.debug('_BatchPublisherProxy: future.result DONE')
        assert result.message_type == Message.CLIENT_BATCH_SUBMIT_RESPONSE
        response = ClientBatchSubmitResponse()
        response.ParseFromString(result.content)
        if response.status != ClientBatchSubmitResponse.OK:
            LOGGER.warning("Submitting batch failed with status %s", response)
Ejemplo n.º 2
0
    def submit_batches(self, batches):
        self._handle_response(Message.CLIENT_BATCH_SUBMIT_REQUEST,
                              ClientBatchSubmitResponse,
                              ClientBatchSubmitRequest(batches=batches))

        id_string = ','.join(b.header_signature for b in batches)
        return self._wrap_response(data=id_string)
Ejemplo n.º 3
0
    def submit_batches(self, data):
        self._handle_response(
            Message.CLIENT_BATCH_SUBMIT_REQUEST, ClientBatchSubmitResponse,
            ClientBatchSubmitRequest(batches=data['batches']))

        id_string = ','.join(b.header_signature for b in data['batches'])
        link = f"{self.url}/batch_statuses?id={id_string}"
        return {'link': link}