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