1 Star 0 Fork 0

BUPT-ZKJC/fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
consortium.go 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
MJL 提交于 2021-08-06 18:37 . first commit
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package channelconfig
import (
cb "github.com/hyperledger/fabric-protos-go/common"
"github.com/pkg/errors"
)
const (
// ChannelCreationPolicyKey is the key used in the consortium config to denote the policy
// to be used in evaluating whether a channel creation request is authorized
ChannelCreationPolicyKey = "ChannelCreationPolicy"
)
// ConsortiumProtos holds the config protos for the consortium config
type ConsortiumProtos struct {
ChannelCreationPolicy *cb.Policy
}
// ConsortiumConfig holds the consortium's configuration information
type ConsortiumConfig struct {
protos *ConsortiumProtos
orgs map[string]Org
}
// NewConsortiumConfig creates a new instance of the consortium's config
func NewConsortiumConfig(consortiumGroup *cb.ConfigGroup, mspConfig *MSPConfigHandler) (*ConsortiumConfig, error) {
cc := &ConsortiumConfig{
protos: &ConsortiumProtos{},
orgs: make(map[string]Org),
}
if err := DeserializeProtoValuesFromGroup(consortiumGroup, cc.protos); err != nil {
return nil, errors.Wrap(err, "failed to deserialize values")
}
for orgName, orgGroup := range consortiumGroup.Groups {
var err error
if cc.orgs[orgName], err = NewOrganizationConfig(orgName, orgGroup, mspConfig); err != nil {
return nil, err
}
}
return cc, nil
}
// Organizations returns the set of organizations in the consortium
func (cc *ConsortiumConfig) Organizations() map[string]Org {
return cc.orgs
}
// CreationPolicy returns the policy structure used to validate
// the channel creation
func (cc *ConsortiumConfig) ChannelCreationPolicy() *cb.Policy {
return cc.protos.ChannelCreationPolicy
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/bupt-zkjc/fabric.git
git@gitee.com:bupt-zkjc/fabric.git
bupt-zkjc
fabric
fabric
98d302355562

搜索帮助