github.com/ewagmig/fabric@v2.1.1+incompatible/common/channelconfig/consortiums.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package channelconfig
     8  
     9  import (
    10  	cb "github.com/hyperledger/fabric-protos-go/common"
    11  )
    12  
    13  const (
    14  	// ConsortiumsGroupKey is the group name for the consortiums config
    15  	ConsortiumsGroupKey = "Consortiums"
    16  )
    17  
    18  // ConsortiumsConfig holds the consoritums configuration information
    19  type ConsortiumsConfig struct {
    20  	consortiums map[string]Consortium
    21  }
    22  
    23  // NewConsortiumsConfig creates a new instance of the consoritums config
    24  func NewConsortiumsConfig(consortiumsGroup *cb.ConfigGroup, mspConfig *MSPConfigHandler) (*ConsortiumsConfig, error) {
    25  	cc := &ConsortiumsConfig{
    26  		consortiums: make(map[string]Consortium),
    27  	}
    28  
    29  	for consortiumName, consortiumGroup := range consortiumsGroup.Groups {
    30  		var err error
    31  		if cc.consortiums[consortiumName], err = NewConsortiumConfig(consortiumGroup, mspConfig); err != nil {
    32  			return nil, err
    33  		}
    34  	}
    35  	return cc, nil
    36  }
    37  
    38  // Consortiums returns a map of the current consortiums
    39  func (cc *ConsortiumsConfig) Consortiums() map[string]Consortium {
    40  	return cc.consortiums
    41  }