1 Star 0 Fork 0

peter/fabric

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
resources.go 1.55 KB
一键复制 编辑 原始数据 按行查看 历史
Jason Yellick 提交于 2017-10-13 02:53 +08:00 . [FAB-6664] Add chaincodes group parsing
/*
Copyright IBM Corp. 2017 All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package resourcesconfig
import (
cb "github.com/hyperledger/fabric/protos/common"
"github.com/pkg/errors"
)
const (
PeerPoliciesGroupKey = "PeerPolicies"
APIsGroupKey = "APIs"
ChaincodesGroupKey = "Chaincodes"
)
// resourceGroup represents the ConfigGroup at the base of the resource configuration.
// Note, the members are always initialized, so that there is no need for nil checks.
type resourceGroup struct {
apisGroup *apisGroup
peerPoliciesGroup *peerPoliciesGroup
chaincodesGroup *chaincodesGroup
}
func newResourceGroup(root *cb.ConfigGroup) (*resourceGroup, error) {
if len(root.Values) > 0 {
return nil, errors.New("/Resources group does not support any values")
}
// initialize the elements with empty implementations, override if actually set
rg := &resourceGroup{
apisGroup: &apisGroup{},
peerPoliciesGroup: &peerPoliciesGroup{},
}
rg.chaincodesGroup, _ = newChaincodesGroup(&cb.ConfigGroup{}) // Initialize to empty
for subGroupName, subGroup := range root.Groups {
var err error
switch subGroupName {
case APIsGroupKey:
rg.apisGroup, err = newAPIsGroup(subGroup)
case PeerPoliciesGroupKey:
rg.peerPoliciesGroup, err = newPeerPoliciesGroup(subGroup)
case ChaincodesGroupKey:
rg.chaincodesGroup, err = newChaincodesGroup(subGroup)
default:
err = errors.New("unknown sub-group")
}
if err != nil {
return nil, errors.Wrapf(err, "error processing group %s", subGroupName)
}
}
return rg, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/peter_code_git/fabric.git
git@gitee.com:peter_code_git/fabric.git
peter_code_git
fabric
fabric
v1.1.1

搜索帮助