代码拉取完成,页面将自动刷新
/*
Copyright IBM Corp. 2017 All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package msp
import (
"github.com/hyperledger/fabric/common/cauthdsl"
"github.com/hyperledger/fabric/msp"
cb "github.com/hyperledger/fabric/protos/common"
mspprotos "github.com/hyperledger/fabric/protos/msp"
"github.com/hyperledger/fabric/protos/utils"
logging "github.com/op/go-logging"
)
var logger = logging.MustGetLogger("configvalues/msp")
const (
// ReadersPolicyKey is the key used for the read policy
ReadersPolicyKey = "Readers"
// WritersPolicyKey is the key used for the read policy
WritersPolicyKey = "Writers"
// AdminsPolicyKey is the key used for the read policy
AdminsPolicyKey = "Admins"
// MSPKey is the org key used for MSP configuration
MSPKey = "MSP"
)
// TemplateGroupMSP creates an MSP ConfigValue at the given configPath
func TemplateGroupMSP(configPath []string, mspConfig *mspprotos.MSPConfig) *cb.ConfigGroup {
// check that the type for that MSP is supported
if mspConfig.Type != int32(msp.FABRIC) {
logger.Panicf("Setup error: unsupported msp type %d", mspConfig.Type)
}
// create the msp instance
mspInst, err := msp.NewBccspMsp()
if err != nil {
logger.Panicf("Creating the MSP manager failed, err %s", err)
}
// set it up
err = mspInst.Setup(mspConfig)
if err != nil {
logger.Panicf("Setting up the MSP manager failed, err %s", err)
}
// add the MSP to the map of pending MSPs
mspID, err := mspInst.GetIdentifier()
if err != nil {
logger.Panicf("Could not extract msp identifier, err %s", err)
}
memberPolicy := &cb.ConfigPolicy{
Policy: &cb.Policy{
Type: int32(cb.Policy_SIGNATURE),
Policy: utils.MarshalOrPanic(cauthdsl.SignedByMspMember(mspID)),
},
}
adminPolicy := &cb.ConfigPolicy{
Policy: &cb.Policy{
Type: int32(cb.Policy_SIGNATURE),
Policy: utils.MarshalOrPanic(cauthdsl.SignedByMspAdmin(mspID)),
},
}
result := cb.NewConfigGroup()
intermediate := result
for _, group := range configPath {
intermediate.Groups[group] = cb.NewConfigGroup()
intermediate = intermediate.Groups[group]
}
intermediate.Values[MSPKey] = &cb.ConfigValue{
Value: utils.MarshalOrPanic(mspConfig),
}
intermediate.Policies[AdminsPolicyKey] = adminPolicy
intermediate.Policies[ReadersPolicyKey] = memberPolicy
intermediate.Policies[WritersPolicyKey] = memberPolicy
return result
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。