Exemple #1
0
    def handle(self, connection_id, message_content):
        # No need to verify this is a valid consensus engine; previous handler
        # ConsensusCheckBlocksHandler has already verifified
        request = consensus_pb2.ConsensusCheckBlocksRequest()

        try:
            request.ParseFromString(message_content)
        except DecodeError:
            LOGGER.exception("Unable to decode ConsensusCheckBlocksRequest")
            return HandlerResult(status=HandlerResult.DROP)

        block_statuses = self._proxy.get_block_statuses(request.block_ids)
        for (block_id, block_status) in block_statuses:
            if block_status == BlockStatus.Valid:
                self._consensus_notifier.notify_block_valid(block_id)
            elif block_status == BlockStatus.Invalid:
                self._consensus_notifier.notify_block_invalid(block_id)
            elif block_status == BlockStatus.Unknown:
                # No need to worry about unknown block, this is checked in the
                # previous handler.
                self._proxy.validate_block(block_id)
            elif block_status == BlockStatus.Missing:
                LOGGER.error("Missing block: %s", block_id)
            elif block_status == BlockStatus.InValidation:
                # Block is already being validated, notification will be sent
                # when it's complete
                pass

        return HandlerResult(status=HandlerStatus.PASS)
Exemple #2
0
    def handle(self, connection_id, message_content):
        request = consensus_pb2.ConsensusCheckBlocksRequest()

        try:
            request.ParseFromString(message_content)
        except DecodeError:
            LOGGER.exception("Unable to decode ConsensusCheckBlocksRequest")
            return HandlerResult(status=HandlerResult.DROP)

        block_statuses = self._proxy.get_block_statuses(request.block_ids)
        for (block_id, block_status) in block_statuses:
            if block_status == BlockStatus.Valid:
                self._consensus_notifier.notify_block_valid(block_id)
            elif block_status == BlockStatus.Invalid:
                self._consensus_notifier.notify_block_invalid(block_id)

        return HandlerResult(status=HandlerStatus.PASS)
Exemple #3
0
    def handle(self, connection_id, message_content):
        request = consensus_pb2.ConsensusCheckBlocksRequest()

        try:
            request.ParseFromString(message_content)
        except DecodeError:
            LOGGER.exception("Unable to decode ConsensusCheckBlocksRequest")
            return HandlerResult(status=HandlerResult.DROP)
        
        block_statuses = self._proxy.get_block_statuses(request.block_ids)
        LOGGER.debug('ConsensusCheckBlocksNotifier: CHECK_BLOCKS_REQUEST get_block_statuses=%s',block_statuses)
        for (block_id, block_status) in block_statuses:
            if block_status == BlockStatus.Valid:
                # at this point notify_block_valid message could be already sent
                self._consensus_notifier.notify_block_valid(block_id)
            elif block_status == BlockStatus.Invalid:
                self._consensus_notifier.notify_block_invalid(block_id)

        return HandlerResult(status=HandlerStatus.PASS)