utils.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:fabric-sdk-py 作者: hyperledger 项目源码 文件源码
def extract_channel_config(configtx_proto_envelope):
    """ Extracts the protobuf 'ConfigUpdate' object out ouf the 'ConfigEnvelope'.

    Args:
        configtx_proto_envelope (common_pb2.Envelope): The encoded bytes of the
            ConfigEnvelope protofbuf.

    Returns:
        config_update (configtx_pb2.ConfigUpadeEnvelope.config_update):
            The encoded bytes of the ConfigUpdate protobuf, ready to be signed

    Raises:
        ValueError: If there is an error in protobuf_decode due to a wrong or
            not valid profobuf file a ValueError is raised.

    """
    _logger.debug('extract_channel_config - start')

    try:
        envelope = common_pb2.Envelope()
        envelope.ParseFromString(configtx_proto_envelope)

        payload = common_pb2.Payload()
        payload.ParseFromString(envelope.payload)

        configtx = configtx_pb2.ConfigUpdateEnvelope()
        configtx.ParseFromString(payload.data)

    except DecodeError as e:
        _logger.error('extract_channel_config - an error occurred decoding'
                      ' the configtx_proto_envelope: {}'.format(e))
        raise ValueError('The given configtx_proto_envelope was not valid: {}'
                         .format(e))

    return configtx.config_update
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号