Пример #1
0
    def _handle_endorser_transaction(self, index, tx, cr,
                                     channel_header, block):
        txStatusCodes = block['metadata']['metadata'][
            BlockMetadataIndex.Value('TRANSACTIONS_FILTER')]

        if cr.tx_id is not None:
            if cr.tx_id == channel_header['tx_id']:
                if txStatusCodes and txStatusCodes[index] != \
                        TxValidationCode.Value('VALID'):
                    exc = TxValidationCode.Name(txStatusCodes[index])
                    raise Exception(exc)
                self._handle_full_chaincode(tx, block, cr)
        else:
            self._handle_full_chaincode(tx, block, cr)
Пример #2
0
    def handle_full_tx(self, block, tx_id, er):
        txStatusCodes = block['metadata']['metadata'][BlockMetadataIndex.Value(
            'TRANSACTIONS_FILTER')]
        for index, data in enumerate(block['data']['data']):
            channel_header = data['payload']['header']['channel_header']
            if tx_id == channel_header['tx_id']:
                if txStatusCodes[index] != TxValidationCode.Value('VALID'):
                    raise Exception(TxValidationCode.Name(
                        txStatusCodes[index]))

                # TODO handle option for not unregistering
                self.unregisterTxEvent(tx_id)
                if er.onEvent is not None:
                    er.onEvent(block)
Пример #3
0
    def handle_full_tx(self, block, tx_id, er):
        for index, data in enumerate(block['data']['data']):
            channel_header = data['payload']['header']['channel_header']
            if tx_id == channel_header['tx_id'] or tx_id == 'all':

                if er.onEvent is not None:
                    txFilter = BlockMetadataIndex.Value('TRANSACTIONS_FILTER')
                    txStatusCodes = block['metadata']['metadata'][txFilter]
                    status = TxValidationCode.Name(txStatusCodes[index])
                    er.onEvent(tx_id, status, block['header']['number'])
                if er.unregister:
                    self.unregisterTxEvent(tx_id)
                if er.disconnect:
                    self.disconnect()
Пример #4
0
    def handle_full_chaincode(self, block, all_events):
        if 'data' in block:
            for index, data in enumerate(block['data']['data']):
                payload = data['payload']
                channel_header = payload['header']['channel_header']

                # only ENDORSER_TRANSACTION have chaincode events
                if channel_header['type'] == 3:
                    tx = payload['data']
                    txFilter = BlockMetadataIndex.Value('TRANSACTIONS_FILTER')
                    txStatusCodes = block['metadata']['metadata'][txFilter]
                    tx_status = TxValidationCode.Name(txStatusCodes[index])
                    tx_id = channel_header['tx_id']
                    self._handle_full_chaincode(tx, block['header']['number'],
                                                tx_id, tx_status, all_events)