代码拉取完成,页面将自动刷新
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package chaincode
import (
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/common/chaincode"
"github.com/hyperledger/fabric/common/flogging"
"github.com/hyperledger/fabric/common/policies"
"github.com/hyperledger/fabric/common/policies/inquire"
common2 "github.com/hyperledger/fabric/protos/common"
)
var logger = flogging.MustGetLogger("discovery.DiscoverySupport")
type MetadataRetriever interface {
Metadata(channel string, cc string, loadCollections bool) *chaincode.Metadata
}
// DiscoverySupport implements support that is used for service discovery
// that is related to chaincode
type DiscoverySupport struct {
ci MetadataRetriever
}
// NewDiscoverySupport creates a new DiscoverySupport
func NewDiscoverySupport(ci MetadataRetriever) *DiscoverySupport {
s := &DiscoverySupport{
ci: ci,
}
return s
}
func (s *DiscoverySupport) PolicyByChaincode(channel string, cc string) policies.InquireablePolicy {
chaincodeData := s.ci.Metadata(channel, cc, false)
if chaincodeData == nil {
logger.Info("Chaincode", cc, "wasn't found")
return nil
}
pol := &common2.SignaturePolicyEnvelope{}
if err := proto.Unmarshal(chaincodeData.Policy, pol); err != nil {
logger.Warning("Failed unmarshaling policy for chaincode", cc, ":", err)
return nil
}
if len(pol.Identities) == 0 || pol.Rule == nil {
logger.Warningf("Invalid policy, either Identities(%v) or Rule(%v) are empty:", pol.Identities, pol.Rule)
return nil
}
return inquire.NewInquireableSignaturePolicy(pol)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。