如何在Hyperledger Fabric中更改频道策略

时间:2018-09-27 08:13:04

标签: hyperledger-fabric hyperledger

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

  

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

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

"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

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

非常感谢您的帮助

1 个答案:

答案 0 :(得分:2)

政策是两种类型

  • 签名政策
  • 隐含元策略

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

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

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

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

回答:创建config.tx时,请在下面进行 变化

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,并且只想指定特定的组织管理员。在以下代码段中使用

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')"