forked from hyperledger/fabric-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
consortiums.go
45 lines (37 loc) · 1.2 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
42
43
44
45
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
/*
Notice: This file has been modified for Hyperledger Fabric SDK Go usage.
Please review third_party pinning scripts and patches for more details.
*/
package channelconfig
import (
cb "github.com/hyperledger/fabric-protos-go/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
}