Beispiel #1
0
def client_batch_submit_request_preprocessor(message_content_bytes):
    request = client_batch_submit_pb2.ClientBatchSubmitRequest()

    try:
        request.ParseFromString(message_content_bytes)
    except DecodeError:
        LOGGER.error('ClientBatchSubmitRequest failed to deserialize')

        return PreprocessorResult(
            status=HandlerStatus.RETURN,
            message_out=ClientBatchSubmitResponse(
                status=ClientBatchSubmitResponse.INTERNAL_ERROR),
            message_type=validator_pb2.Message.CLIENT_BATCH_SUBMIT_RESPONSE)

    return PreprocessorResult(content=request)
Beispiel #2
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)
Beispiel #3
0
def gossip_block_response_preprocessor(message_content_bytes):
    block_response = GossipBlockResponse()
    block_response.ParseFromString(message_content_bytes)
    block = Block()
    block.ParseFromString(block_response.content)

    content = block, message_content_bytes

    return PreprocessorResult(content=content)
Beispiel #4
0
def gossip_message_preprocessor(message_content_bytes):
    gossip_message = GossipMessage()
    gossip_message.ParseFromString(message_content_bytes)

    tag = gossip_message.content_type

    if tag == GossipMessage.BLOCK:
        obj = Block()
        obj.ParseFromString(gossip_message.content)
    elif tag == GossipMessage.BATCH:
        obj = Batch()
        obj.ParseFromString(gossip_message.content)

    content = obj, tag, gossip_message.time_to_live

    return PreprocessorResult(content=content)