Hyperledger fabric's ChannelCreationPolicy

2020-08-01 02:40发布

问题:

I am struggling so hard to write policy for creating channel (ChannelCreationPolicy) here is my configtx.yaml

---
Organizations:
- &OrdererOrg
  Name: OrdererOrg
  ID: OrdererMSP
  MSPDir: ../crypto-config/ordererOrganizations/orderer-org/msp
- &ShopOrg
  Name: ShopOrgMSP
  ID: ShopOrgMSP
  MSPDir: ../crypto-config/peerOrganizations/shop-org/msp
  AnchorPeers:
  - Host: shop-peer-0
    Port: 7051


Orderer: &OrdererDefaults
  OrdererType: solo
  Addresses:
  - orderer0:7050
  BatchTimeout: 2s
  BatchSize:
    MaxMessageCount: 10
    AbsoluteMaxBytes: 99 MB
    PreferredMaxBytes: 512 KB
  Organizations:

Application: &ApplicationDefaults
  Organizations:

Profiles:
  TwoOrgGenesis:
    Orderer:
      <<: *OrdererDefaults
      Organizations:
      - *OrdererOrg
    Consortiums:
      InsuranceConsortium:
        # ChannelCreationPolicy:
        #   Admins:
        #     Type: Signature
        #     Rule: "OR('ShopOrgMSP.admin')"
        Organizations:
        - *ShopOrg
  TwoOrgChannel:
    Consortium: InsuranceConsortium
    Application:
      <<: *ApplicationDefaults
      Organizations:
      - *ShopOrg

I tried to put ChannelCreationPolicy block above in the commented area but it says : 'Profiles[TwoOrgGenesis].Consortiums[InsuranceConsortium]' has invalid keys: ChannelCreationPolicy

I can't find place for ChannelCreationPolicy inside that .yaml. So how can I write policy so that, for example, only ShopOrgMSP admins could create channel?

回答1:

Looking at the source for configtxgen, it doesn't look like channel creation policies are supported by the tool. You would need to submit this change as a config update transaction.

Unfortunately, this is a highly non-trivial process, but at least there is an example (for adding an org to a channel) here.