如何在Hyperledger Fabric中更改频道策略 [英] How to change channel policy in Hyperledger Fabric

查看:116
本文介绍了如何在Hyperledger Fabric中更改频道策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Hyperledger Farbic创建了网络. 加密-证书是使用configtxgen工具创建的, 因此,我创建了以下频道tx:

I have created network using Hyperledger Farbic. Crypto - certificates was created with configtxgen tool, So, i created channel tx with:

configtxgen -profile SampleChannel -outputCreateChannelTx ./config/SampleChannel.tx -channelID SampleChannel

configtxgen -profile SampleChannel -outputCreateChannelTx ./config/SampleChannel.tx -channelID SampleChannel

因此,默认情况下,管理员

So, by default Admins

"policies": {
"Admins": {
"mod_policy": "Admins",
"policy": {
  "type": 3,
  "value": {
    "rule": "MAJORITY",
    "sub_policy": "Admins"
  }
},
"version": "0"
}

如何将mod_policy更改为

"policies": {
"Admins": {
"mod_policy": "Admins",
"policy": {
  "type": 3,
  "value": {
    "rule": "ANY", // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    "sub_policy": "Admins"
  }
},
"version": "0"
}

我的下一步是

configtxgen -profile SampleChannel -outputAnchorPeersUpdate ./config/SampleChannel.tx -channelID SampleChannel -asOrg Org1MSP

configtxgen -profile SampleChannel -outputAnchorPeersUpdate ./config/SampleChannel.tx -channelID SampleChannel -asOrg Org1MSP

但是如何使用手动更改的SampleChannel.tx将其应用于网络?

But how can I use manually changed SampleChannel.tx to apply it to network?

非常感谢您的帮助

推荐答案

策略是两种类型

  • 签名策略
  • 隐含元策略

Signature policies 这些策略标识了必须签名才能满足策略的特定用户.

Signature policies These policies identify specific users who must sign in order for a policy to be satisfied.

For Example:
    Policies:
      MyPolicy:
        Type: Signature
        Rule: "Org1.Peer OR Org2.Peer"

ImplicitMeta policies ImplicitMeta策略将策略的结果汇总到更深层的配置层次结构中,最终由签名策略定义.它们支持默认规则,例如大多数组织管理员".与签名策略相比,这些策略使用不同但仍然非常简单的语法:<ALL|ANY|MAJORITY> <sub_policy>.

ImplicitMeta policies ImplicitMeta policies aggregate the result of policies deeper into the configuration hierarchy that are ultimately defined by Signature policies. They support default rules like "A majority of the organization admins". These policies use a different but still very simple syntax as compared to Signature policies: <ALL|ANY|MAJORITY> <sub_policy>.

For example ANY Readers or MAJORITY Admins.
Policies:
  MyPolicy:
    Type: ImplicitMeta
    Rule: "MAJORITY Admins"

回答您的问题:在创建config.tx时,请在下面进行说明 变化

Coming to your Answer: While creating the config.tx Please make below changes

Channel: &ChannelDefaults
    Policies:
        # Who may invoke the 'Deliver' API
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        # Who may invoke the 'Broadcast' API
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        # By default, who may modify elements at this config level
        Admins:
            Type: ImplicitMeta
            Rule: "ANY Writers"

如果您想要更具体的信息而不是NAY Writers,并且只想指定特定的组织管理员.在以下代码段中使用

If you want more specific instead of NAY Writers and want to specify only particular organization Admins. Use below snippet

Channel: &ChannelDefaults
    Policies:
        # Who may invoke the 'Deliver' API
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        # Who may invoke the 'Broadcast' API
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        # By default, who may modify elements at this config level
        Admins:
            Type: Signature
            Rule: "OR('Org1.admin')" 

这篇关于如何在Hyperledger Fabric中更改频道策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆