def build_header(creator,
                 nonce,
                 tran_prop_type,
                 chain,
                 prop_type,
                 epoch=0,
                 chaincode_id=None):
    """Build a header for transaction proposal.

    Args:
        prop_type: prop type
        creator: user
        nonce: nonce
        tran_prop_type: transaction proposal type
        chain: chain instance
        epoch: epoch
        chaincode_id: chaincode id

    Returns: common_proto.Header instance

    """
    header = common_pb2.Header()

    signature_header = common_pb2.SignatureHeader()
    signature_header.creator = creator.serialize()
    signature_header.nonce = nonce
    header.signature_header = signature_header.SerializeToString()

    channel_header = common_pb2.ChannelHeader()
    channel_header.type = tran_prop_type
    channel_header.version = 1
    if prop_type != CC_INSTALL:
        channel_header.channel_id = proto_str(chain.name)
    channel_header.tx_id = proto_str(chain.generate_tx_id(nonce, creator))
    channel_header.epoch = epoch
    if chaincode_id:
        header_ext = proposal_pb2.ChaincodeHeaderExtension()
        header_ext.chaincode_id.name = proto_str(chaincode_id)
        channel_header.extension = header_ext.SerializeToString()
    header.channel_header = channel_header.SerializeToString()

    return header
Exemple #2
0
def build_header(creator, channel_header, nonce):
    """This function will build the common header.

    :param creator: Serialized identity of the creator.
    :type creator: protobuf SerializedIdentity
    :param channel_header: ChannelHeader
    :type channel_header: protobuf ChannelHeader
    :param nonce: Nonce that has been used for the tx_id.
    :type nonce: str
    :return: Returns created protobuf common header.
    :rtype: header
    """
    signature_header = common_pb2.SignatureHeader()
    signature_header.creator = creator
    signature_header.nonce = nonce

    header = common_pb2.Header()
    header.signature_header = signature_header.SerializeToString()
    header.channel_header = channel_header.SerializeToString()

    return header
Exemple #3
0
def build_header(creator, channel_header, nonce):
    """This function will build the common header.

    Args:
        creator (protobuf SerializedIdentity):
            Serialized identity of the creator.
        channel_header (protobuf ChannelHeader): ChannelHeader
        nonce (str): Nonce that has been used for the tx_id.

    Returns:
        header: Returns created protobuf common header.

    """
    signature_header = common_pb2.SignatureHeader()
    signature_header.creator = creator
    signature_header.nonce = nonce

    header = common_pb2.Header()
    header.signature_header = signature_header.SerializeToString()
    header.channel_header = channel_header.SerializeToString()

    return header