Пример #1
0
def gossip_batch_response_preprocessor(message_content_bytes):
    batch_response = GossipBatchResponse()
    batch_response.ParseFromString(message_content_bytes)
    batch = Batch()
    batch.ParseFromString(batch_response.content)

    content = batch, message_content_bytes

    return PreprocessorResult(content=content)
Пример #2
0
    def handle(self, connection_id, message_content):
        ack = NetworkAcknowledgement()
        ack.status = ack.OK
        batch_response_message = GossipBatchResponse()
        batch_response_message.ParseFromString(message_content)

        return HandlerResult(HandlerStatus.RETURN_AND_PASS,
                             message_out=ack,
                             message_type=validator_pb2.Message.NETWORK_ACK)
    def handle(self, connection_id, message_content):
        batch_response_message = GossipBatchResponse()
        batch_response_message.ParseFromString(message_content)

        batch = Batch()
        batch.ParseFromString(batch_response_message.content)
        if not is_valid_batch(batch):
            LOGGER.debug("requested batch's structure is invalid: %s",
                         batch.header_signature)
            return HandlerResult(status=HandlerStatus.DROP)

        return HandlerResult(status=HandlerStatus.PASS)
Пример #4
0
    def handle(self, connection_id, message_content):
        batch_response_message = GossipBatchResponse()
        batch_response_message.ParseFromString(message_content)

        batch = Batch()
        batch.ParseFromString(batch_response_message.content)
        status = validate_batch(batch)

        if status is True:
            LOGGER.debug("requested batch passes signature verification %s",
                         batch.header_signature)
            return HandlerResult(status=HandlerStatus.PASS)
        else:
            LOGGER.debug("requested batch's signature is invalid: %s",
                         batch.header_signature)
            return HandlerResult(status=HandlerStatus.DROP)
Пример #5
0
    def handle(self, connection_id, message_content):
        batch_response_message = GossipBatchResponse()
        batch_response_message.ParseFromString(message_content)

        batch = Batch()
        batch.ParseFromString(batch_response_message.content)
        if batch.header_signature in self._seen_cache:
            self._batch_dropped_count.inc()
            return HandlerResult(status=HandlerStatus.DROP)

        if not is_valid_batch(batch):
            LOGGER.debug("requested batch's signature is invalid: %s",
                         batch.header_signature)
            return HandlerResult(status=HandlerStatus.DROP)

        self._seen_cache[batch.header_signature] = None
        return HandlerResult(status=HandlerStatus.PASS)
Пример #6
0
    def handle(self, connection_id, message_content):
        batch_response_message = GossipBatchResponse()
        batch_response_message.ParseFromString(message_content)
        batch = Batch()
        batch.ParseFromString(batch_response_message.content)

        batch_id = batch.header_signature

        if not self._has_open_requests(batch_id) and self._has_batch(batch_id):
            LOGGER.debug('Drop duplicate batch: %s', batch_id)
            return HandlerResult(HandlerStatus.RETURN)

        ack = NetworkAcknowledgement()
        ack.status = ack.OK

        return HandlerResult(HandlerStatus.RETURN_AND_PASS,
                             message_out=ack,
                             message_type=validator_pb2.Message.NETWORK_ACK)