parameters: (self, consensus, orderers, peers, orderer_cfg=None, application=None, option=None)
docstring: create the cryptotx.yaml
                  param:
                      consensus:consensus
                      orderers:the list of orderer
                      peers: the list of peer
                      orderer_cfg: the config of orderer
                      application: application
                      option: option
                  return:
docstring_summary: create the cryptotx.yaml
                  param:
                      consensus:consensus
                      orderers:the list of orderer
                      peers: the list of peer
                      orderer_cfg: the config of orderer
                      application: application
                      option: option
                  return:
docstring_tokens: create the cryptotx . yaml param : consensus : consensus orderers : the list of orderer peers : the list of peer orderer_cfg : the config of orderer application : application option : option return :
function: def create(self, consensus, orderers, peers, orderer_cfg=None, application=None, option=None):
          """create the cryptotx.yaml
                  param:
                      consensus:consensus
                      orderers:the list of orderer
                      peers: the list of peer
                      orderer_cfg: the config of orderer
                      application: application
                      option: option
                  return:
          """ 
          OrdererDefaults = self.template["Orderer"]
          ChannelDefaults = self.template["Channel"]
          ApplicationDefaults = self.template["Application"]
          ChannelCapabilities = self.template["Capabilities"]["Channel"]
          OrdererCapabilities = self.template["Capabilities"]["Orderer"]
          ApplicationCapabilities = self.template["Capabilities"]["Application"]         
          
          OrdererOrganizations = []
          OrdererAddress = []
          Consenters = []
          
          for orderer in orderers:
              OrdererMSP = orderer["name"].capitalize()+"Orderer"
              OrdererOrg = dict(Name=orderer["name"].split(".")[0].capitalize() + "Orderer",
                                               ID='{}MSP'.format(OrdererMSP),
                                               MSPDir='{}/{}/crypto-config/ordererOrganizations/{}/msp'.format(self.filepath,orderer["name"],orderer['name'].split(".", 1)[1]),
                                               Policies=dict(Readers=dict(Type="Signature",Rule="OR('{}MSP.member')".format(OrdererMSP)),
                                                             Writers=dict(Type="Signature",Rule="OR('{}MSP.member')".format(OrdererMSP)),
                                                             Admins=dict(Type="Signature",Rule="OR('{}MSP.admin')".format(OrdererMSP)))
                          )
              for host in orderer['hosts']:
                  OrdererAddress.append('{}.{}:{}'.format(host['name'], orderer['name'].split(".", 1)[1], 7050))
                  Consenters.append(dict(
                      Host='{}.{}'.format(host['name'], orderer['name'].split(".", 1)[1]),
                      Port=7050,
                      ClientTLSCert='{}/{}/crypto-config/ordererOrganizations/{}/orderers/{}.{}/tls/server.crt'
                                             .format(self.filepath, orderer['name'], orderer['name'].split(".", 1)[1],host['name'], orderer['name'].split(".", 1)[1]),
                      ServerTLSCert='{}/{}/crypto-config/ordererOrganizations/{}/orderers/{}.{}/tls/server.crt'
                                             .format(self.filepath, orderer['name'], orderer['name'].split(".", 1)[1], host['name'], orderer['name'].split(".", 1)[1])))
              OrdererOrg["OrdererEndpoints"] = deepcopy(OrdererAddress)
              OrdererOrganizations.append(OrdererOrg)
  
          PeerOrganizations = []
  
          for peer in peers:
              PeerMSP = peer["name"].capitalize()
              PeerOrganizations.append(dict(Name=peer["name"].split(".")[0].capitalize(),
                                            ID='{}MSP'.format(PeerMSP),
                                            MSPDir='{}/{}/crypto-config/peerOrganizations/{}/msp'.format(self.filepath,peer['name'],peer['name']),
                                            #AnchorPeers=[{'Port': peer["hosts"][0]["port"], 'Host': '{}.{}'.format(peer["hosts"][0]["name"],peer["name"])}],
                                            Policies=dict(Readers=dict(Type="Signature",Rule="OR('{}MSP.peer', '{}MSP.admin','{}MSP.client')".format(PeerMSP,PeerMSP,PeerMSP)),
                                                          Writers=dict(Type="Signature",Rule="OR('{}MSP.admin','{}MSP.client')".format(PeerMSP,PeerMSP)),
                                                          Admins=dict(Type="Signature",Rule="OR('{}MSP.admin')".format(PeerMSP)))
                                            ))
          Organizations = OrdererOrganizations + PeerOrganizations
          Capabilities = dict(
              Channel=ChannelCapabilities,
              Orderer=OrdererCapabilities,
              Application=ApplicationCapabilities
          )
          Application = deepcopy(ApplicationDefaults)
          Application["Capabilities"] = Capabilities["Application"]
          Orderer = deepcopy(OrdererDefaults)
          Orderer["Addresses"] = deepcopy(OrdererAddress)
          Orderer["Policies"] = dict(
                  Readers=dict(Type="ImplicitMeta", Rule="ANY Readers"),
                  Writers=dict(Type="ImplicitMeta", Rule="ANY Writers"),
                  Admins=dict(Type="ImplicitMeta", Rule="MAJORITY Admins"),
                  BlockValidation=dict(Type="ImplicitMeta",Rule="ANY Writers")
              )
          Orderer["EtcdRaft"]["Consenters"] = deepcopy(Consenters)
          Channel = deepcopy(ChannelDefaults)
          Channel["Capabilities"] = Capabilities["Channel"]
          Profiles = {}
          Profiles["TwoOrgsOrdererGenesis"] = deepcopy(Channel)
          Profiles["TwoOrgsOrdererGenesis"]["Orderer"] = deepcopy(Orderer)
          Profiles["TwoOrgsOrdererGenesis"]["Orderer"]["Organizations"] = OrdererOrganizations
          Profiles["TwoOrgsOrdererGenesis"]["Orderer"]["Capabilities"] = Capabilities["Orderer"]
          Profiles["TwoOrgsOrdererGenesis"]["Consortiums"] = {'SampleConsortium': {'Organizations': deepcopy(PeerOrganizations)}}
  
          configtx = dict(
              Organizations=Organizations,
              Capabilities=Capabilities,
              Application=Application,
              Orderer=Orderer,
              Channel=Channel,
              Profiles=Profiles
          )
          os.system('mkdir -p {}/{}'.format(self.filepath, self.network))
  
          with open('{}/{}/configtx.yaml'.format(self.filepath, self.network), 'w', encoding='utf-8') as f:
              yaml.dump(configtx, f, sort_keys=False)
function_tokens: def create ( self , consensus , orderers , peers , orderer_cfg = None , application = None , option = None ) : OrdererDefaults = self . template [ "Orderer" ] ChannelDefaults = self . template [ "Channel" ] ApplicationDefaults = self . template [ "Application" ] ChannelCapabilities = self . template [ "Capabilities" ] [ "Channel" ] OrdererCapabilities = self . template [ "Capabilities" ] [ "Orderer" ] ApplicationCapabilities = self . template [ "Capabilities" ] [ "Application" ] OrdererOrganizations = [ ] OrdererAddress = [ ] Consenters = [ ] for orderer in orderers : OrdererMSP = orderer [ "name" ] . capitalize ( ) + "Orderer" OrdererOrg = dict ( Name = orderer [ "name" ] . split ( "." ) [ 0 ] . capitalize ( ) + "Orderer" , ID = '{}MSP' . format ( OrdererMSP ) , MSPDir = '{}/{}/crypto-config/ordererOrganizations/{}/msp' . format ( self . filepath , orderer [ "name" ] , orderer [ 'name' ] . split ( "." , 1 ) [ 1 ] ) , Policies = dict ( Readers = dict ( Type = "Signature" , Rule = "OR('{}MSP.member')" . format ( OrdererMSP ) ) , Writers = dict ( Type = "Signature" , Rule = "OR('{}MSP.member')" . format ( OrdererMSP ) ) , Admins = dict ( Type = "Signature" , Rule = "OR('{}MSP.admin')" . format ( OrdererMSP ) ) ) ) for host in orderer [ 'hosts' ] : OrdererAddress . append ( '{}.{}:{}' . format ( host [ 'name' ] , orderer [ 'name' ] . split ( "." , 1 ) [ 1 ] , 7050 ) ) Consenters . append ( dict ( Host = '{}.{}' . format ( host [ 'name' ] , orderer [ 'name' ] . split ( "." , 1 ) [ 1 ] ) , Port = 7050 , ClientTLSCert = '{}/{}/crypto-config/ordererOrganizations/{}/orderers/{}.{}/tls/server.crt' . format ( self . filepath , orderer [ 'name' ] , orderer [ 'name' ] . split ( "." , 1 ) [ 1 ] , host [ 'name' ] , orderer [ 'name' ] . split ( "." , 1 ) [ 1 ] ) , ServerTLSCert = '{}/{}/crypto-config/ordererOrganizations/{}/orderers/{}.{}/tls/server.crt' . format ( self . filepath , orderer [ 'name' ] , orderer [ 'name' ] . split ( "." , 1 ) [ 1 ] , host [ 'name' ] , orderer [ 'name' ] . split ( "." , 1 ) [ 1 ] ) ) ) OrdererOrg [ "OrdererEndpoints" ] = deepcopy ( OrdererAddress ) OrdererOrganizations . append ( OrdererOrg ) PeerOrganizations = [ ] for peer in peers : PeerMSP = peer [ "name" ] . capitalize ( ) PeerOrganizations . append ( dict ( Name = peer [ "name" ] . split ( "." ) [ 0 ] . capitalize ( ) , ID = '{}MSP' . format ( PeerMSP ) , MSPDir = '{}/{}/crypto-config/peerOrganizations/{}/msp' . format ( self . filepath , peer [ 'name' ] , peer [ 'name' ] ) , #AnchorPeers=[{'Port': peer["hosts"][0]["port"], 'Host': '{}.{}'.format(peer["hosts"][0]["name"],peer["name"])}], Policies = dict ( Readers = dict ( Type = "Signature" , Rule = "OR('{}MSP.peer', '{}MSP.admin','{}MSP.client')" . format ( PeerMSP , PeerMSP , PeerMSP ) ) , Writers = dict ( Type = "Signature" , Rule = "OR('{}MSP.admin','{}MSP.client')" . format ( PeerMSP , PeerMSP ) ) , Admins = dict ( Type = "Signature" , Rule = "OR('{}MSP.admin')" . format ( PeerMSP ) ) ) ) ) Organizations = OrdererOrganizations + PeerOrganizations Capabilities = dict ( Channel = ChannelCapabilities , Orderer = OrdererCapabilities , Application = ApplicationCapabilities ) Application = deepcopy ( ApplicationDefaults ) Application [ "Capabilities" ] = Capabilities [ "Application" ] Orderer = deepcopy ( OrdererDefaults ) Orderer [ "Addresses" ] = deepcopy ( OrdererAddress ) Orderer [ "Policies" ] = dict ( Readers = dict ( Type = "ImplicitMeta" , Rule = "ANY Readers" ) , Writers = dict ( Type = "ImplicitMeta" , Rule = "ANY Writers" ) , Admins = dict ( Type = "ImplicitMeta" , Rule = "MAJORITY Admins" ) , BlockValidation = dict ( Type = "ImplicitMeta" , Rule = "ANY Writers" ) ) Orderer [ "EtcdRaft" ] [ "Consenters" ] = deepcopy ( Consenters ) Channel = deepcopy ( ChannelDefaults ) Channel [ "Capabilities" ] = Capabilities [ "Channel" ] Profiles = { } Profiles [ "TwoOrgsOrdererGenesis" ] = deepcopy ( Channel ) Profiles [ "TwoOrgsOrdererGenesis" ] [ "Orderer" ] = deepcopy ( Orderer ) Profiles [ "TwoOrgsOrdererGenesis" ] [ "Orderer" ] [ "Organizations" ] = OrdererOrganizations Profiles [ "TwoOrgsOrdererGenesis" ] [ "Orderer" ] [ "Capabilities" ] = Capabilities [ "Orderer" ] Profiles [ "TwoOrgsOrdererGenesis" ] [ "Consortiums" ] = { 'SampleConsortium' : { 'Organizations' : deepcopy ( PeerOrganizations ) } } configtx = dict ( Organizations = Organizations , Capabilities = Capabilities , Application = Application , Orderer = Orderer , Channel = Channel , Profiles = Profiles ) os . system ( 'mkdir -p {}/{}' . format ( self . filepath , self . network ) ) with open ( '{}/{}/configtx.yaml' . format ( self . filepath , self . network ) , 'w' , encoding = 'utf-8' ) as f : yaml . dump ( configtx , f , sort_keys = False )