代码拉取完成,页面将自动刷新
/*
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 policies
import (
cb "github.com/hyperledger/fabric-protos-go/common"
"gitee.com/hyperledger-fabric-gm/fabric-sdk-go/internal/github.com/hyperledger/fabric/protoutil"
)
// ConfigPolicy defines a common representation for different *cb.ConfigPolicy values.
type ConfigPolicy interface {
// Key is the key this value should be stored in the *cb.ConfigGroup.Policies map.
Key() string
// Value is the backing policy implementation for this ConfigPolicy
Value() *cb.Policy
}
// StandardConfigValue implements the ConfigValue interface.
type StandardConfigPolicy struct {
key string
value *cb.Policy
}
// Key is the key this value should be stored in the *cb.ConfigGroup.Values map.
func (scv *StandardConfigPolicy) Key() string {
return scv.key
}
// Value is the *cb.Policy which should be stored as the *cb.ConfigPolicy.Policy.
func (scv *StandardConfigPolicy) Value() *cb.Policy {
return scv.value
}
func makeImplicitMetaPolicy(subPolicyName string, rule cb.ImplicitMetaPolicy_Rule) *cb.Policy {
return &cb.Policy{
Type: int32(cb.Policy_IMPLICIT_META),
Value: protoutil.MarshalOrPanic(&cb.ImplicitMetaPolicy{
Rule: rule,
SubPolicy: subPolicyName,
}),
}
}
// ImplicitMetaAllPolicy defines an implicit meta policy whose sub_policy and key is policyname with rule ALL.
func ImplicitMetaAllPolicy(policyName string) *StandardConfigPolicy {
return &StandardConfigPolicy{
key: policyName,
value: makeImplicitMetaPolicy(policyName, cb.ImplicitMetaPolicy_ALL),
}
}
// ImplicitMetaAnyPolicy defines an implicit meta policy whose sub_policy and key is policyname with rule ANY.
func ImplicitMetaAnyPolicy(policyName string) *StandardConfigPolicy {
return &StandardConfigPolicy{
key: policyName,
value: makeImplicitMetaPolicy(policyName, cb.ImplicitMetaPolicy_ANY),
}
}
// ImplicitMetaMajorityPolicy defines an implicit meta policy whose sub_policy and key is policyname with rule MAJORITY.
func ImplicitMetaMajorityPolicy(policyName string) *StandardConfigPolicy {
return &StandardConfigPolicy{
key: policyName,
value: makeImplicitMetaPolicy(policyName, cb.ImplicitMetaPolicy_MAJORITY),
}
}
// SignaturePolicy defines a policy with key policyName and the given signature policy.
func SignaturePolicy(policyName string, sigPolicy *cb.SignaturePolicyEnvelope) *StandardConfigPolicy {
return &StandardConfigPolicy{
key: policyName,
value: &cb.Policy{
Type: int32(cb.Policy_SIGNATURE),
Value: protoutil.MarshalOrPanic(sigPolicy),
},
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。